forked from nigma/django-easy-pdf
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathruntests.py
62 lines (48 loc) · 1.61 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#-*- coding: utf-8 -*-
import os
import sys
from optparse import OptionParser
from django.conf import settings
def rel(*path):
return os.path.abspath(
os.path.join(os.path.dirname(__file__), *path)
).replace("\\", "/")
if not settings.configured or not os.environ.get("DJANGO_SETTINGS_MODULE"):
settings.configure(
DEBUG=True,
USE_TZ=True,
DATABASES={
"default": {
"ENGINE": "django.db.backends.sqlite3",
}
},
INSTALLED_APPS=[
"easy_pdf"
],
TEMPLATE_DIRS=[rel("tests", "templates")],
STATIC_ROOT=os.path.abspath(rel("tests", "static")),
ROOT_URLCONF="tests.urls",
)
from django.test.utils import get_runner
def run_tests(verbosity, interactive, failfast, test_labels):
if not test_labels:
test_labels = ["tests"]
if not hasattr(settings, "TEST_RUNNER"):
settings.TEST_RUNNER = "django.test.runner.DiscoverRunner"
TestRunner = get_runner(settings)
test_runner = TestRunner(
verbosity=verbosity,
interactive=interactive,
failfast=failfast
)
failures = test_runner.run_tests(test_labels)
if failures:
sys.exit(bool(failures))
if __name__ == "__main__":
parser = OptionParser()
parser.add_option("--failfast", action="store_true",
default=False, dest="failfast")
parser.add_option("--verbosity", action="store",
default=1, type=int, dest="verbosity")
(options, args) = parser.parse_args()
run_tests(options.verbosity, options.failfast, False, args)