-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathruntests.py
executable file
·41 lines (31 loc) · 1.05 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
from django.conf import settings
import django
def get_settings():
import test_settings
setting_attrs = {}
for attr in dir(test_settings):
if attr.isupper():
setting_attrs[attr] = getattr(test_settings, attr)
return setting_attrs
def runtests():
if not settings.configured:
settings.configure(**get_settings())
# Compatibility with Django 1.7's stricter initialization
if hasattr(django, 'setup'):
django.setup()
parent = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, parent)
from django.test.runner import DiscoverRunner as Runner
# reminder to self: an ImportError in the tests may either turn up
# or may cause this thing to barf with this crap:
# AttributeError: 'module' object has no attribute 'tests'
test_args = ['.']
failures = Runner(
verbosity=2, interactive=True, failfast=False).run_tests(test_args)
sys.exit(failures)
if __name__ == '__main__':
runtests()