Skip to content

Commit f83b6d9

Browse files
committed
Trigger Django system checks before running the test suite.
1 parent 7621d70 commit f83b6d9

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

hvad/test_utils/cli.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ def configure(**extra):
1616
defaults = dict(
1717
CACHE_BACKEND = 'locmem:///',
1818
DEBUG = True,
19-
TEMPLATE_DEBUG = True,
2019
DATABASE_SUPPORTS_TRANSACTIONS = True,
2120
DATABASES = {'default': config(default='sqlite://localhost/hvad.db')},
2221
TEST_DATABASE_CHARSET = "utf8",
@@ -30,20 +29,18 @@ def configure(**extra):
3029
ADMIN_MEDIA_PREFIX = '/static/admin/',
3130
EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend',
3231
SECRET_KEY = 'key',
33-
TEMPLATE_LOADERS = ( # Remove when dropping support for Django 1.7
34-
'django.template.loaders.filesystem.Loader',
35-
'django.template.loaders.app_directories.Loader',
36-
),
37-
TEMPLATE_DIRS = [ # Remove when dropping support for Django 1.7
38-
os.path.abspath(os.path.join(os.path.dirname(__file__), 'project', 'templates'))
39-
],
4032
TEMPLATES = [
4133
{
4234
'BACKEND': 'django.template.backends.django.DjangoTemplates',
4335
'DIRS': [
4436
os.path.abspath(os.path.join(os.path.dirname(__file__), 'project', 'templates'))
4537
],
4638
'APP_DIRS': True,
39+
'OPTIONS': {
40+
'context_processors': [
41+
'django.contrib.auth.context_processors.auth',
42+
],
43+
}
4744
},
4845
],
4946
MIDDLEWARE_CLASSES = [
@@ -77,6 +74,21 @@ def configure(**extra):
7774
'django.contrib.auth.hashers.MD5PasswordHasher',
7875
)
7976
)
77+
if django.VERSION < (1, 8):
78+
defaults.update(dict(
79+
TEMPLATE_DEBUG = True,
80+
TEMPLATE_CONTEXT_PROCESSORS = ( # Remove when dropping support for Django 1.7
81+
'django.contrib.auth.context_processors.auth',
82+
),
83+
TEMPLATE_LOADERS = ( # Remove when dropping support for Django 1.7
84+
'django.template.loaders.filesystem.Loader',
85+
'django.template.loaders.app_directories.Loader',
86+
),
87+
TEMPLATE_DIRS = [ # Remove when dropping support for Django 1.7
88+
os.path.abspath(os.path.join(os.path.dirname(__file__), 'project', 'templates'))
89+
],
90+
))
91+
8092
defaults.update(extra)
8193
settings.configure(**defaults)
8294
from django.contrib import admin

runtests.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python
22
from __future__ import with_statement
3+
from django.utils.encoding import force_str
34
from hvad.test_utils.cli import configure
45
from hvad.test_utils.tmpdir import temp_dir
56
import argparse
@@ -14,6 +15,13 @@ def main(test_runner='hvad.test_utils.runners.NormalTestRunner', junit_output_di
1415
with temp_dir() as MEDIA_ROOT:
1516
configure(LANGUAGE_CODE='en', TEST_RUNNER=test_runner, JUNIT_OUTPUT_DIR=junit_output_dir,
1617
TIME_TESTS=time_tests, STATIC_ROOT=STATIC_ROOT, MEDIA_ROOT=MEDIA_ROOT)
18+
from django.core import checks
19+
errors = checks.run_checks()
20+
if errors:
21+
for error in errors:
22+
print(force_str(error))
23+
sys.exit(len(errors))
24+
1725
from django.conf import settings
1826
from django.test.utils import get_runner
1927
TestRunner = get_runner(settings)

0 commit comments

Comments
 (0)