-
Notifications
You must be signed in to change notification settings - Fork 5
/
run_tests.py
executable file
·41 lines (33 loc) · 1.2 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
#!/usr/bin/env python
import sys
import logging
logging.disable(logging.CRITICAL)
from argparse import ArgumentParser
from coverage import coverage
import tests.config
from django.test.simple import DjangoTestSuiteRunner
def run_tests(verbosity, *test_args):
if not test_args:
test_args = ['url_tracker']
test_runner = DjangoTestSuiteRunner(verbosity=verbosity)
num_failures = test_runner.run_tests(test_args)
if num_failures:
sys.exit(num_failures)
if __name__ == '__main__':
parser = ArgumentParser()
parser.add_argument('-c', '--coverage', dest='use_coverage', default=False,
action='store_true', help="Generate coverage report")
parser.add_argument('-v', '--verbosity', dest='verbosity', default=1,
type=int, help="Verbosity of output")
options, args = parser.parse_known_args()
if options.use_coverage:
print 'Running tests with coverage'
c = coverage(source=['url_tracker'])
c.start()
run_tests(options.verbosity, *args)
c.stop()
print 'Generate HTML reports'
c.html_report()
else:
print 'Running tests'
run_tests(options.verbosity, *args)