-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunit_test.py
More file actions
36 lines (26 loc) · 858 Bytes
/
unit_test.py
File metadata and controls
36 lines (26 loc) · 858 Bytes
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
"""Run all unit tests."""
import unittest
from test.test_convert import TestConvert
from test.test_html_sanitize import TestHtmlSanitize
test_cases = [
TestConvert,
TestHtmlSanitize
]
"""Test cases to run with `unit-test.sh`."""
def get_suite() -> unittest.TestSuite:
"""Collect all unit tests to run together.
Returns:
TestSuite with all unit tests defined in `test_cases`.
"""
suites = []
for test_case in test_cases:
case_suite = unittest.defaultTestLoader.loadTestsFromTestCase(test_case)
suites.append(case_suite)
suite = unittest.TestSuite()
suite.addTests(suites)
num_tests = suite.countTestCases()
print("Found {count} tests in suite.".format(count=num_tests))
return suite
if __name__ == '__main__':
runner = unittest.TextTestRunner()
runner.run(get_suite())