-
Notifications
You must be signed in to change notification settings - Fork 115
/
run_tests.py
executable file
·48 lines (38 loc) · 1.12 KB
/
run_tests.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
#!/usr/bin/env python
import os
import sys
import argparse
# By default, tests will be run for these apps.
# Other tests can be specified via command-line arguments.
DEFAULT_APPS = [
'timepiece',
'timepiece.contracts',
'timepiece.crm',
'timepiece.entries',
'timepiece.reports',
]
parser = argparse.ArgumentParser(
description="Run tests for the django-timepiece application.")
parser.add_argument(
'apps',
nargs="*",
)
parser.add_argument(
'--settings',
dest="settings",
default="example_project.settings.tests",
help="Django settings file to use.",
)
def run_django_tests(settings, apps):
os.environ['DJANGO_SETTINGS_MODULE'] = settings
import django
if hasattr(django, 'setup'): # Django 1.7+
django.setup()
from django.conf import settings
from django.test.utils import get_runner
runner = get_runner(settings)(verbosity=1, interactive=True, failfast=False)
failures = runner.run_tests(apps or DEFAULT_APPS)
sys.exit(failures)
if __name__ == '__main__':
options = parser.parse_args()
run_django_tests(options.settings, options.apps)