forked from peterldowns/djoauth2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtests.py
executable file
·51 lines (41 loc) · 1.59 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
#!/usr/bin/env python
# coding: utf-8
import sys
from argparse import ArgumentParser
from os.path import abspath
from os.path import dirname
# Modify the path so that our djoauth2 app is in it.
parent_dir = dirname(abspath(__file__))
sys.path.insert(0, parent_dir)
# Load Django-related settings; necessary for tests to run and for Django
# imports to work.
import local_settings
# Now, imports from Django will work properly without raising errors related to
# missing or badly-configured settings.
from django.test.simple import DjangoTestSuiteRunner
from django.conf import settings
def runtests(verbosity, failfast, interactive, test_labels):
if 'south' in settings.INSTALLED_APPS:
from south.management.commands import patch_for_test_db_setup
patch_for_test_db_setup()
test_runner = DjangoTestSuiteRunner(
verbosity=verbosity,
interactive=interactive,
failfast=failfast)
sys.exit(test_runner.run_tests(test_labels))
if __name__ == '__main__':
# Parse any command line arguments.
parser = ArgumentParser()
parser.add_argument('--failfast',
action='store_true',
default=False,
dest='failfast')
parser.add_argument('--interactive',
action='store_true',
default=False,
dest='interactive')
parser.add_argument('--verbosity', default=1, type=int)
parser.add_argument('test_labels', nargs='*', default=('djoauth2',))
args = parser.parse_args()
# Run the tests.
runtests(args.verbosity, args.failfast, args.interactive, args.test_labels)