-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathrun_tests.py
49 lines (34 loc) · 1.1 KB
/
run_tests.py
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
46
47
48
49
#!/usr/bin/env python
import sys
import django
def main():
print(
"\n\n\n%s\n Python: %s, Django: %s\n%s\n"
% (
"=" * 120,
".".join(map(str, sys.version_info[:3])),
".".join(map(str, django.VERSION[:3])),
"-" * 120,
)
)
import logging
logging.basicConfig(level=logging.ERROR)
from conftest import pytest_configure
settings = pytest_configure()
from django.test.utils import get_runner
test_runner = get_runner(settings)(verbosity=2, interactive=True)
original_suite_result = test_runner.suite_result
def patched_suite_result(suite, result, **kwargs):
from formapi.tests import TOTAL_TESTS
assert (
result.testsRun == TOTAL_TESTS
), "Run {} tests, expected to run {}".format(
result.testsRun,
TOTAL_TESTS,
)
return original_suite_result(suite, result, **kwargs)
test_runner.suite_result = patched_suite_result
failures = test_runner.run_tests(["formapi"])
sys.exit(failures)
if __name__ == "__main__":
main()