-
Notifications
You must be signed in to change notification settings - Fork 32
/
run_tests.py
executable file
·46 lines (34 loc) · 1.08 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
#!/usr/bin/env python
import coverage
import django
import optparse
import os
import sys
from django.conf import settings
from django.test.utils import get_runner
if not settings.configured:
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_settings")
def run_tests():
parser = optparse.OptionParser()
parser.add_option('--coverage', dest='coverage', default='2',
help="coverage level, 0=no coverage, 1=without branches,"
" 2=with branches")
options, tests = parser.parse_args()
tests = tests or ['fitapp']
covlevel = int(options.coverage)
if covlevel:
branch = covlevel == 2
cov = coverage.coverage(branch=branch, config_file='.coveragerc')
cov.load()
cov.start()
django.setup()
TestRunner = get_runner(settings)
test_runner = TestRunner(verbosity=1, interactive=True, failfast=False)
exit_val = test_runner.run_tests(tests)
if covlevel:
cov.stop()
cov.save()
cov.html_report()
sys.exit(exit_val)
if __name__ == '__main__':
run_tests()