aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2022-08-29 02:17:55 -0400
committerLibravatarUnit 193 <unit193@unit193.net>2022-08-29 02:17:55 -0400
commit1507bc65ae118b321ea745cdbe877236d7da3ded (patch)
treead3773db43840362ebc7231c270e464c2b6a7be5
parentba3ac631ac4e8820d3d701980782ab4a03c1276b (diff)
d/t/run-tests.py: Re-sync from upstream, upgrade from nose to unittests.
Closes: #1018363
-rw-r--r--debian/tests/control2
-rw-r--r--debian/tests/run-tests.py54
2 files changed, 39 insertions, 17 deletions
diff --git a/debian/tests/control b/debian/tests/control
index 6724131..531cfa0 100644
--- a/debian/tests/control
+++ b/debian/tests/control
@@ -1,3 +1,3 @@
Tests: run-tests.py
-Depends: @, @builddeps@, python3-nose
+Depends: @, @builddeps@
Restrictions: allow-stderr
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)