forked from brack3t/Djrill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruntests.py
59 lines (51 loc) · 1.44 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
52
53
54
55
56
57
58
59
# python setup.py test
# or
# python runtests.py
import sys
from django.conf import settings
APP = 'djrill'
settings.configure(
DEBUG=True,
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
}
},
ROOT_URLCONF=APP+'.urls',
INSTALLED_APPS=(
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
APP,
),
MIDDLEWARE_CLASSES=(
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
),
TEMPLATES=[
# Djrill doesn't have any templates, but tests need a TEMPLATES
# setting to avoid warnings from the Django 1.8+ test client.
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
},
],
)
try:
# Django 1.7+ initialize app registry
from django import setup
setup()
except ImportError:
pass
try:
from django.test.runner import DiscoverRunner as TestRunner # Django 1.6+
except ImportError:
from django.test.simple import DjangoTestSuiteRunner as TestRunner # Django -1.5
def runtests():
test_runner = TestRunner(verbosity=1)
failures = test_runner.run_tests([APP])
sys.exit(failures)
if __name__ == '__main__':
runtests()