-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_runner.py
More file actions
44 lines (32 loc) · 1.47 KB
/
test_runner.py
File metadata and controls
44 lines (32 loc) · 1.47 KB
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
44
import unittest
import argparse
parser = argparse.ArgumentParser(description='IonImage embedding testrunner')
parser.add_argument('test_suite', type=str, const='all', nargs='?', default='all',
help='Which tests to run: "all", "dataloader", "crl", "lightningCRL", (default: "all")',)
args = parser.parse_args()
scenario = args.test_suite
test_suite = unittest.TestSuite()
loader = unittest.TestLoader()
if scenario == 'all':
print('Running all tests')
from tests import test_dataloader, test_crl, test_lightningCRL
test_suite.addTests(loader.loadTestsFromModule(test_dataloader))
test_suite.addTests(loader.loadTestsFromModule(test_crl))
test_suite.addTests(loader.loadTestsFromModule(test_lightningCRL))
elif scenario == 'dataloader':
print('Running dataloader tests')
from tests import test_dataloader
test_suite.addTests(loader.loadTestsFromModule(test_dataloader))
elif scenario == 'crl':
print('Running crl tests')
from tests import test_crl
test_suite.addTests(loader.loadTestsFromModule(test_crl))
elif scenario == 'lightningCRL':
print('Running lightningCRL tests')
from tests import test_lightningCRL
test_suite.addTests(loader.loadTestsFromModule(test_lightningCRL))
else:
raise ValueError(f'ValueError: Testsuite "{scenario}" unknown. Please open the script help (python test_runner.py -h)')
runner = unittest.TextTestRunner()
result = runner.run(test_suite)
exit(0 if result.wasSuccessful() else 1)