Skip to content

Commit

Permalink
Trigger Django system checks before running the test suite.
Browse files Browse the repository at this point in the history
  • Loading branch information
spectras committed Aug 9, 2016
1 parent 7621d70 commit f83b6d9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
28 changes: 20 additions & 8 deletions hvad/test_utils/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def configure(**extra):
defaults = dict(
CACHE_BACKEND = 'locmem:///',
DEBUG = True,
TEMPLATE_DEBUG = True,
DATABASE_SUPPORTS_TRANSACTIONS = True,
DATABASES = {'default': config(default='sqlite://localhost/hvad.db')},
TEST_DATABASE_CHARSET = "utf8",
Expand All @@ -30,20 +29,18 @@ def configure(**extra):
ADMIN_MEDIA_PREFIX = '/static/admin/',
EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend',
SECRET_KEY = 'key',
TEMPLATE_LOADERS = ( # Remove when dropping support for Django 1.7
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
),
TEMPLATE_DIRS = [ # Remove when dropping support for Django 1.7
os.path.abspath(os.path.join(os.path.dirname(__file__), 'project', 'templates'))
],
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.abspath(os.path.join(os.path.dirname(__file__), 'project', 'templates'))
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.contrib.auth.context_processors.auth',
],
}
},
],
MIDDLEWARE_CLASSES = [
Expand Down Expand Up @@ -77,6 +74,21 @@ def configure(**extra):
'django.contrib.auth.hashers.MD5PasswordHasher',
)
)
if django.VERSION < (1, 8):
defaults.update(dict(
TEMPLATE_DEBUG = True,
TEMPLATE_CONTEXT_PROCESSORS = ( # Remove when dropping support for Django 1.7
'django.contrib.auth.context_processors.auth',
),
TEMPLATE_LOADERS = ( # Remove when dropping support for Django 1.7
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
),
TEMPLATE_DIRS = [ # Remove when dropping support for Django 1.7
os.path.abspath(os.path.join(os.path.dirname(__file__), 'project', 'templates'))
],
))

defaults.update(extra)
settings.configure(**defaults)
from django.contrib import admin
Expand Down
8 changes: 8 additions & 0 deletions runtests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python
from __future__ import with_statement
from django.utils.encoding import force_str
from hvad.test_utils.cli import configure
from hvad.test_utils.tmpdir import temp_dir
import argparse
Expand All @@ -14,6 +15,13 @@ def main(test_runner='hvad.test_utils.runners.NormalTestRunner', junit_output_di
with temp_dir() as MEDIA_ROOT:
configure(LANGUAGE_CODE='en', TEST_RUNNER=test_runner, JUNIT_OUTPUT_DIR=junit_output_dir,
TIME_TESTS=time_tests, STATIC_ROOT=STATIC_ROOT, MEDIA_ROOT=MEDIA_ROOT)
from django.core import checks
errors = checks.run_checks()
if errors:
for error in errors:
print(force_str(error))
sys.exit(len(errors))

from django.conf import settings
from django.test.utils import get_runner
TestRunner = get_runner(settings)
Expand Down

0 comments on commit f83b6d9

Please sign in to comment.