blob: feadfbd918c002c692e27bc3056a2cd517e7ace9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
import importlib
import os
import sys
blacklist = {"test_wasserstein_distance", "test_wasserstein_barycenter", "test_knn", "test_subsampling", "test_representations", "test_dtm"}
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]
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)
|