| 1 |
#!/usr/bin/env python3 |
| 2 |
"""Script to run the tests.""" |
| 3 |
|
| 4 |
import sys |
| 5 |
import unittest |
| 6 |
|
| 7 |
# Change PYTHONPATH to include dependencies. |
| 8 |
sys.path.insert(0, ".") |
| 9 |
|
| 10 |
import utils.dependencies # pylint: disable=wrong-import-position |
| 11 |
|
| 12 |
if __name__ == "__main__": |
| 13 |
print(f"Using Python version {sys.version!s}") |
| 14 |
|
| 15 |
fail_unless_has_test_file = "--fail-unless-has-test-file" in sys.argv |
| 16 |
setattr(unittest, "fail_unless_has_test_file", fail_unless_has_test_file) |
| 17 |
if fail_unless_has_test_file: |
| 18 |
# Remove --fail-unless-has-test-file otherwise it will conflict with |
| 19 |
# the argparse tests. |
| 20 |
sys.argv.remove("--fail-unless-has-test-file") |
| 21 |
|
| 22 |
dependency_helper = utils.dependencies.DependencyHelper() |
| 23 |
|
| 24 |
if not dependency_helper.CheckTestDependencies(): |
| 25 |
sys.exit(1) |
| 26 |
|
| 27 |
test_suite = unittest.TestLoader().discover("tests", pattern="*.py") |
| 28 |
test_results = unittest.TextTestRunner(verbosity=2).run(test_suite) |
| 29 |
if not test_results.wasSuccessful(): |
| 30 |
sys.exit(1) |