summaryrefslogtreecommitdiff
path: root/tests/handlers
diff options
context:
space:
mode:
authorFlorian Apolloner <florian@apolloner.eu>2015-11-07 16:12:37 +0100
committerTim Graham <timograham@gmail.com>2016-05-17 07:22:22 -0400
commit9baf692a58de78dba13aa582098781675367c329 (patch)
tree1926555441d0c3b13185782dce193b839d616a4a /tests/handlers
parent05c888ffb843ba3eff06cd07b3cef5bbb513a54f (diff)
downloaddjango-9baf692a58de78dba13aa582098781675367c329.tar.gz
Fixed #26601 -- Improved middleware per DEP 0005.
Thanks Tim Graham for polishing the patch, updating the tests, and writing documentation. Thanks Carl Meyer for shepherding the DEP.
Diffstat (limited to 'tests/handlers')
-rw-r--r--tests/handlers/tests.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/handlers/tests.py b/tests/handlers/tests.py
index d0b161cf44..9f01cb201a 100644
--- a/tests/handlers/tests.py
+++ b/tests/handlers/tests.py
@@ -4,6 +4,7 @@ from __future__ import unicode_literals
import unittest
+from django.core.exceptions import ImproperlyConfigured
from django.core.handlers.wsgi import WSGIHandler, WSGIRequest, get_script_name
from django.core.signals import request_finished, request_started
from django.db import close_old_connections, connection
@@ -166,6 +167,10 @@ class SignalsTests(SimpleTestCase):
self.assertEqual(self.signals, ['started', 'finished'])
+def empty_middleware(get_response):
+ pass
+
+
@override_settings(ROOT_URLCONF='handlers.urls')
class HandlerRequestTests(SimpleTestCase):
@@ -199,6 +204,12 @@ class HandlerRequestTests(SimpleTestCase):
WSGIHandler()(environ, start_response)
self.assertEqual(start_response.status, '200 OK')
+ @override_settings(MIDDLEWARE=['handlers.tests.empty_middleware'])
+ def test_middleware_returns_none(self):
+ msg = 'Middleware factory handlers.tests.empty_middleware returned None.'
+ with self.assertRaisesMessage(ImproperlyConfigured, msg):
+ self.client.get('/')
+
class ScriptNameTests(SimpleTestCase):
def test_get_script_name(self):