-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests.py
executable file
·39 lines (33 loc) · 1.75 KB
/
run_tests.py
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
#!/usr/bin/env python
import argparse
import unittest
from test import setUpModule, tearDownModule
from test import test_directory_service, test_recording, test_playlist, test_station, test_player, test_podcast
suites = {
"importer": unittest.defaultTestLoader.loadTestsFromModule(test_directory_service),
"recording": unittest.defaultTestLoader.loadTestsFromModule(test_recording),
"playlist": unittest.defaultTestLoader.loadTestsFromModule(test_playlist),
"station": unittest.defaultTestLoader.loadTestsFromModule(test_station),
"player": unittest.defaultTestLoader.loadTestsFromModule(test_player),
"podcast": unittest.defaultTestLoader.loadTestsFromModule(test_podcast),
}
if __name__ == "__main__":
parser = argparse.ArgumentParser("test runner for music library")
parser.add_argument("-s", "--suites", metavar = "NAME", dest = "suites", nargs = "+", default = suites,
help = "run tests from %(metavar)s: options are " + ", ".join(suites.keys()))
parser.add_argument("-x", "--exclude", dest = "exclude", action = "store_true",
help = "exclude rather than run suite(s)")
parser.add_argument("-v", "--verbosity", metavar = "LEVEL", dest = "verbosity", type = int, default = 2,
help = "use verbosity level %(metavar)s [default %(default)d]")
args = parser.parse_args()
setUpModule()
runner = unittest.TextTestRunner(verbosity = args.verbosity)
for name, suite in suites.items():
print(f"\nResults for {name}")
if name in args.suites and not args.exclude:
runner.run(suite)
elif name not in args.suites and args.exclude:
runner.run(suite)
else:
print("skipped")
tearDownModule()