-
Notifications
You must be signed in to change notification settings - Fork 164
/
runtests.py
38 lines (28 loc) · 899 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
36
37
38
import os
import sys
try:
sys.path.append('demoproject')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "demoproject.settings")
from django.conf import settings
from django.core.management import call_command
settings.DATABASES['default']['NAME'] = ':memory:'
try:
import django
setup = django.setup
except AttributeError:
pass
else:
setup()
except ImportError:
import traceback
traceback.print_exc()
raise ImportError("To fix this error, run: pip install -r requirements.txt")
def run_tests(*test_args):
if not test_args:
test_args = ["demoproject"]
# ./manage.py test takes care of database creation and
# application of migrations if any
result = call_command('test', *test_args, verbosity=2, failfast=True)
sys.exit(result)
if __name__ == "__main__":
run_tests(*sys.argv[1:])