forked from torchbox/django-pattern-library
-
Notifications
You must be signed in to change notification settings - Fork 1
/
runtests.py
executable file
·45 lines (37 loc) · 984 Bytes
/
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
#!/usr/bin/env python
import argparse
import os
import sys
import django
from django.conf import settings
from django.test.utils import get_runner
import coverage
parser = argparse.ArgumentParser()
parser.add_argument(
"-v",
"--verbosity",
action="store",
dest="verbosity",
default=1,
type=int,
choices=range(4),
help="Verbosity level; 0=minimal output, 1=normal output, 2=verbose output, 3=very verbose output",
)
if __name__ == "__main__":
# Coverage setup
cov = coverage.Coverage()
cov.start()
# Django setup
os.environ["DJANGO_SETTINGS_MODULE"] = "tests.settings.dev"
django.setup()
# Test runner setup
TestRunner = get_runner(settings)
TestRunner.add_arguments(parser)
args = parser.parse_args()
test_runner = TestRunner(**vars(args))
failures = test_runner.run_tests(["tests"])
# Generate coverage report
cov.stop()
cov.save()
cov.html_report()
sys.exit(bool(failures))