forked from jazzband/sorl-thumbnail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruntests.py
executable file
·57 lines (52 loc) · 1.67 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
#!/usr/bin/env python
import os
import sys
from os.path import abspath, dirname, join as pjoin
from django.conf import settings
def runtests(verbosity=1, interactive=True, failfast=True, settings_module='settings.default'):
here = abspath(dirname(__file__))
root = pjoin(here, os.pardir)
sys.path[0:0] = [ here, root, pjoin(root, 'sorl') ]
os.environ['DJANGO_SETTINGS_MODULE'] = settings_module
from django.test.utils import get_runner
print "Running tests for '%s'" % settings_module
TestRunner = get_runner(settings)
test_runner = TestRunner(
verbosity=verbosity, interactive=interactive, failfast=failfast
)
return test_runner.run_tests(settings.INSTALLED_APPS)
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser(
description='Runs the test suite for sorl-thumbnail.'
)
parser.add_argument(
'--settings',
dest='settings_module',
action='store',
default='settings.default',
help='Specify settings module.',
)
parser.add_argument(
'--noinput',
dest='interactive',
action='store_false',
default=True,
help='Do not prompt the user for input of any kind.',
)
parser.add_argument(
'--failfast',
dest='failfast',
action='store_true',
default=False,
help='Stop running the test suite after first failed test.',
)
args = parser.parse_args()
failures = runtests(
verbosity=1,
interactive=args.interactive,
failfast=args.failfast,
settings_module=args.settings_module,
)
if failures:
sys.exit(bool(failures))