-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathrun_all_tests
executable file
·43 lines (33 loc) · 1007 Bytes
/
run_all_tests
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
43
#!/usr/bin/env python3
import importlib
import os
import os.path
from tests.util.test import TestFunctionType
def all_modules_in(pkg):
return (
path[:-3].replace("/", ".") for path in
(
os.path.join(root, f)
for root, _, files in os.walk("tests")
for f in files
)
if path.endswith(".py") and not path.endswith("__init__.py")
)
def all_tests_in(mod):
return (
(mod.__name__ + "." + name, fn) for name, fn
in mod.__dict__.items() if isinstance(fn, TestFunctionType)
)
count = 0
for modpath in all_modules_in("tests"):
mod = importlib.import_module(modpath)
tests = list(all_tests_in(mod))
if len(tests) > 0:
print(" %s .. " % mod.__name__, end="")
for (name, test) in tests:
test()
print("%d tests passed" % len(tests))
count += len(tests)
if count == 0:
raise AssertionError("No tests were found!")
print("All %d tests passed." % count)