forked from KohakuBlueleaf/LyCORIS
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathunit-test.py
More file actions
45 lines (37 loc) · 1.18 KB
/
Copy pathunit-test.py
File metadata and controls
45 lines (37 loc) · 1.18 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
45
import unittest
import logging
import coverage
import sys
cov = coverage.Coverage()
cov.start()
from lycoris.logging import logger
logger.setLevel(logging.ERROR)
TESTS = [
("test.module", "LycorisModuleTests"),
("test.functional", "LycorisFunctionalTests"),
("test.wrapper", "LycorisWrapperTests"),
("test.kohya", "LycorisKohyaWrapperTests"),
]
if __name__ == "__main__":
test_loader = unittest.TestLoader()
runner = unittest.TextTestRunner(verbosity=2)
all_suites = []
for module_name, test_name in TESTS:
try:
mod = __import__(module_name, fromlist=[test_name])
test_case = getattr(mod, test_name)
suite = test_loader.loadTestsFromTestCase(test_case)
all_suites.append(suite)
except ImportError as e:
print(f"SKIPPING {module_name}.{test_name}: import error - {e}")
if not all_suites:
print("No test suites could be loaded!")
sys.exit(1)
combined = unittest.TestSuite(all_suites)
result = runner.run(combined)
cov.stop()
cov.save()
cov.report()
cov.html_report(directory="coverage_report")
if not result.wasSuccessful():
sys.exit(1)