diff options
Diffstat (limited to 'debian/tests/run-tests.py')
| -rw-r--r-- | debian/tests/run-tests.py | 54 |
1 files changed, 38 insertions, 16 deletions
diff --git a/debian/tests/run-tests.py b/debian/tests/run-tests.py index 11feaed..c73db63 100644 --- a/debian/tests/run-tests.py +++ b/debian/tests/run-tests.py @@ -1,23 +1,45 @@ -#!/bin/bash -# This is a slightly modified version of upstream's scripts/run_tests.py +#!/usr/bin/python3 +# -*- coding: utf-8 -*- -TESTS_CORE=(cache config cookies downloader extractor oauth postprocessor text util) -TESTS_RESULTS=(results) +# Copyright 2021 Mike Fährmann +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +import os +import sys +import unittest -# select tests -case "${1:-${GALLERYDL_TESTS:-core}}" in - core) TESTS=( ${TESTS_CORE[@]} );; - results) TESTS=( ${TESTS_RESULTS[@]} );; - *) TESTS=( );; -esac +TEST_DIRECTORY = "test" +sys.path.insert(0, TEST_DIRECTORY) -# transform each array element to test_###.py -TESTS=( ${TESTS[@]/#/test_} ) -TESTS=( ${TESTS[@]/%/.py} ) +if len(sys.argv) <= 1: + TESTS = [ + file.rpartition(".")[0] + for file in os.listdir(TEST_DIRECTORY) + if file.startswith("test_") and file != "test_results.py" + ] +else: + TESTS = [ + name if name.startswith("test_") else "test_" + name + for name in sys.argv[1:] + ] -# run 'nosetests3' with selected tests -# (or all tests if ${TESTS} is empty) -nosetests3 --verbose -w "test" ${TESTS[@]} +suite = unittest.TestSuite() + +for test in TESTS: + try: + module = __import__(test) + except ImportError: + print("unable to import", test) + else: + tests = unittest.defaultTestLoader.loadTestsFromModule(module) + suite.addTests(tests) + +if __name__ == "__main__": + result = unittest.TextTestRunner(verbosity=2).run(suite) + if result.errors or result.failures: + sys.exit(1) |
