Fix compatibility for older versions of Django

This commit is contained in:
Gertjan Oude Lohuis 2017-04-18 14:24:21 +02:00
parent 35532634fa
commit 26b2efe361
2 changed files with 11 additions and 4 deletions

View file

@ -1,4 +1,8 @@
from django.utils.deprecation import MiddlewareMixin
try:
# https://docs.djangoproject.com/en/1.10/topics/http/middleware/#upgrading-pre-django-1-10-style-middleware
from django.utils.deprecation import MiddlewareMixin
except ImportError:
MiddlewareMixin = object
from oidc_provider import settings
from oidc_provider.lib.utils.common import get_browser_state_or_default

View file

@ -1,6 +1,6 @@
from django.conf.urls import url
from django.test import TestCase, override_settings
from django.views import View
from django.views.generic import View
from mock import mock
@ -10,10 +10,13 @@ class StubbedViews:
urlpatterns = [url('^test/', SampleView.as_view())]
MW_CLASSES = ('django.contrib.sessions.middleware.SessionMiddleware',
'oidc_provider.middleware.SessionManagementMiddleware')
@override_settings(ROOT_URLCONF=StubbedViews,
MIDDLEWARE=('django.contrib.sessions.middleware.SessionMiddleware',
'oidc_provider.middleware.SessionManagementMiddleware'),
MIDDLEWARE=MW_CLASSES,
MIDDLEWARE_CLASSES=MW_CLASSES,
OIDC_SESSION_MANAGEMENT_ENABLE=True)
class MiddlewareTestCase(TestCase):