-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathrun_tests.py
More file actions
executable file
·30 lines (22 loc) · 993 Bytes
/
run_tests.py
File metadata and controls
executable file
·30 lines (22 loc) · 993 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
#!/usr/bin/env python3
"""Script to run the tests."""
import sys
import unittest
# Change PYTHONPATH to include dependencies.
sys.path.insert(0, ".")
import utils.dependencies # pylint: disable=wrong-import-position
if __name__ == "__main__":
print(f"Using Python version {sys.version!s}")
fail_unless_has_test_file = "--fail-unless-has-test-file" in sys.argv
setattr(unittest, "fail_unless_has_test_file", fail_unless_has_test_file)
if fail_unless_has_test_file:
# Remove --fail-unless-has-test-file otherwise it will conflict with
# the argparse tests.
sys.argv.remove("--fail-unless-has-test-file")
dependency_helper = utils.dependencies.DependencyHelper()
if not dependency_helper.CheckTestDependencies():
sys.exit(1)
test_suite = unittest.TestLoader().discover("tests", pattern="*.py")
test_results = unittest.TextTestRunner(verbosity=2).run(test_suite)
if not test_results.wasSuccessful():
sys.exit(1)