forked from gregmuellegger/django-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtests.py
executable file
·46 lines (32 loc) · 1.18 KB
/
runtests.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 argparse
import os, sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'django_mobile_tests.settings'
# Adding current directory to ``sys.path``.
parent = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, parent)
def runtests(*argv):
argv = list(argv) or [
'django_mobile',
'django_mobile_tests',
]
opts = argparser.parse_args(argv)
if opts.coverage:
from coverage import coverage
test_coverage = coverage(
branch=True,
source=['django_mobile'])
test_coverage.start()
# Run tests.
from django.core.management import execute_from_command_line
execute_from_command_line([sys.argv[0], 'test'] + opts.appname)
if opts.coverage:
test_coverage.stop()
# Report coverage to commandline.
test_coverage.report(file=sys.stdout)
argparser = argparse.ArgumentParser(description='Process some integers.')
argparser.add_argument('appname', nargs='*')
argparser.add_argument('--no-coverage', dest='coverage', action='store_const',
const=False, default=True, help='Do not collect coverage data.')
if __name__ == '__main__':
runtests(*sys.argv[1:])