diff options
author | Gard Spreemann <gspr@nonempty.org> | 2020-07-10 10:46:55 +0200 |
---|---|---|
committer | Gard Spreemann <gspr@nonempty.org> | 2020-07-10 10:46:55 +0200 |
commit | 9b580182e9213abbcf28d6682722bb1fe4e5caff (patch) | |
tree | 296728c565308453301e4613f23021b687697220 /debian/tests/upstream.py | |
parent | 3cabcd4d18424af8140b89d2e26661a0cbb3f6fe (diff) |
Leverage PyTest to simplify autopkgtests.
Diffstat (limited to 'debian/tests/upstream.py')
-rw-r--r-- | debian/tests/upstream.py | 48 |
1 files changed, 12 insertions, 36 deletions
diff --git a/debian/tests/upstream.py b/debian/tests/upstream.py index 869d469e..c21aff8d 100644 --- a/debian/tests/upstream.py +++ b/debian/tests/upstream.py @@ -1,42 +1,18 @@ -import importlib -import os import sys +import itertools +import pytest -blacklist = {"test_knn", "test_subsampling", "test_representations", "test_dtm"} +blacklist = ["test_dtm.py", # Requires hnswlib + "test_knn.py", # Requires pykeops + "test_representations.py", # Look into this + "test_wasserstein_distance.py::test_wasserstein_distance_pot", # Requires eagerpy. + "test_wasserstein_distance.py::test_wasserstein_distance_grad" # Requires eagerpy. + ] -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[:-3] +print("Blacklist: %s" %(str(blacklist))) - 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) +testdir = sys.argv[1] - 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) +deselect_args = list(itertools.chain.from_iterable([["--deselect", "%s/%s" %(testdir, exclude)] for exclude in blacklist])) -if all(results): - exit(0) -else: - exit(1) +pytest.main([testdir] + deselect_args) |