Skip to content

Commit 18b147d

Browse files
michael-kdulacp
authored andcommitted
tests: use new-style middleware
Closes blueyed#2.
1 parent 434b206 commit 18b147d

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

pytest_django_test/settings_base.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import os
22

3+
import django
4+
35
ROOT_URLCONF = 'pytest_django_test.urls'
46
INSTALLED_APPS = [
57
'django.contrib.auth',
@@ -21,13 +23,17 @@
2123
else:
2224
db_suffix = ''
2325

24-
MIDDLEWARE_CLASSES = (
26+
MIDDLEWARE = [
2527
'django.contrib.sessions.middleware.SessionMiddleware',
2628
'django.middleware.common.CommonMiddleware',
2729
'django.middleware.csrf.CsrfViewMiddleware',
2830
'django.contrib.auth.middleware.AuthenticationMiddleware',
2931
'django.contrib.messages.middleware.MessageMiddleware',
30-
)
32+
]
33+
34+
if django.VERSION < (1, 10):
35+
MIDDLEWARE_CLASSES = MIDDLEWARE
36+
3137

3238
TEMPLATES = [
3339
{

tests/conftest.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ def django_testdir(request, testdir, monkeypatch):
4343
db_settings['default']['TEST']['NAME'] = TEST_DB_NAME
4444

4545
test_settings = dedent('''
46+
import django
47+
4648
# Pypy compatibility
4749
try:
4850
from psycopg2ct import compat
@@ -60,13 +62,16 @@ def django_testdir(request, testdir, monkeypatch):
6062
]
6163
SECRET_KEY = 'foobar'
6264
63-
MIDDLEWARE_CLASSES = (
65+
MIDDLEWARE = [
6466
'django.contrib.sessions.middleware.SessionMiddleware',
6567
'django.middleware.common.CommonMiddleware',
6668
'django.middleware.csrf.CsrfViewMiddleware',
6769
'django.contrib.auth.middleware.AuthenticationMiddleware',
6870
'django.contrib.messages.middleware.MessageMiddleware',
69-
)
71+
]
72+
73+
if django.VERSION < (1, 10):
74+
MIDDLEWARE_CLASSES = MIDDLEWARE
7075
7176
TEMPLATES = [
7277
{

0 commit comments

Comments
 (0)