forked from martsberger/django-pivot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruntests.py
35 lines (26 loc) · 955 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
import os
import sys
from optparse import OptionParser
def parse_args():
parser = OptionParser()
parser.add_option('-s', '--settings', help='Define settings.')
parser.add_option('-t', '--unittest', help='Define which test to run. Default all.')
options, args = parser.parse_args()
if not options.settings:
parser.print_help()
sys.exit(1)
if not options.unittest:
options.unittest = ['pivot']
return options
if __name__ == '__main__':
options = parse_args()
os.environ['DJANGO_SETTINGS_MODULE'] = options.settings
# Local imports because DJANGO_SETTINGS_MODULE needs to be set first
import django
from django.test.utils import get_runner
from django.conf import settings
if hasattr(django, 'setup'):
django.setup()
TestRunner = get_runner(settings)
runner = TestRunner(verbosity=1, interactive=True, failfast=False)
sys.exit(runner.run_tests([]))