diff options
author | Gard Spreemann <gspr@nonempty.org> | 2020-06-06 15:10:43 +0200 |
---|---|---|
committer | Gard Spreemann <gspr@nonempty.org> | 2020-06-06 15:10:43 +0200 |
commit | 1b1b19eecd4eced58d94e575fa59942431f37406 (patch) | |
tree | ade0ab8a55877b9380aabaed4f154dd06967a9bd | |
parent | 72c35697e940fe87a02ae01fffb041d709d62527 (diff) |
Fix broken autopkgtests.
-rwxr-xr-x | debian/tests/python-upstream.sh | 8 | ||||
-rw-r--r-- | debian/tests/upstream.py | 42 |
2 files changed, 45 insertions, 5 deletions
diff --git a/debian/tests/python-upstream.sh b/debian/tests/python-upstream.sh index a83dfdcc..499cc0f2 100755 --- a/debian/tests/python-upstream.sh +++ b/debian/tests/python-upstream.sh @@ -3,15 +3,13 @@ set -e set -u +helper=$PWD/debian/tests/upstream.py testdir=$PWD/src/python/test cd $AUTOPKGTEST_TMP for py3ver in $(py3versions -vs) do echo "Running tests with Python ${py3ver}." - for t in $(find $testdir -type f -name 'test_*.py') - do - echo "Running test ${t}." - /usr/bin/python${py3ver} -B $t - done + /usr/bin/python${py3ver} -B $helper $testdir + echo "**********" done diff --git a/debian/tests/upstream.py b/debian/tests/upstream.py new file mode 100644 index 00000000..a1b7af1b --- /dev/null +++ b/debian/tests/upstream.py @@ -0,0 +1,42 @@ +import importlib +import os +import sys + +blacklist = {"test_wasserstein_distance", "test_wasserstein_barycenter"} + +testdir = sys.argv[1] +sys.path.append(testdir) + +results = [] +with os.scandir(testdir) as it: + for entry in it: + if entry.is_file() and entry.name.startswith("test_") and entry.name.endswith(".py"): + name = entry.name.rstrip(".py") + + if name in blacklist: + print("Skipping tests in %s due to blacklist." %(name)) + else: + print("Running tests from %s." %(name)) + + module = importlib.import_module(name) + + tests = [f for f in dir(module) if str(f).startswith("test_")] + for t in tests: + func = getattr(module, t) + if callable(func): + print(" ", t) + ok = True + try: + func() + except AssertionError: + ok = False + if ok: + print(" OK!") + else: + print(" FAIL!") + results.append(ok) + +if all(results): + exit(0) +else: + exit(1) |