mirror of
https://github.com/django/django.git
synced 2025-10-24 22:26:08 +00:00
Added tests for middlewares' checks.
This commit is contained in:
committed by
Mariusz Felisiak
parent
2847d2c760
commit
d4e767911f
@@ -27,3 +27,13 @@ class TestAuthenticationMiddleware(TestCase):
|
||||
self.assertTrue(self.request.user.is_anonymous)
|
||||
# session should be flushed
|
||||
self.assertIsNone(self.request.session.session_key)
|
||||
|
||||
def test_no_session(self):
|
||||
msg = (
|
||||
"The Django authentication middleware requires session middleware "
|
||||
"to be installed. Edit your MIDDLEWARE setting to insert "
|
||||
"'django.contrib.sessions.middleware.SessionMiddleware' before "
|
||||
"'django.contrib.auth.middleware.AuthenticationMiddleware'."
|
||||
)
|
||||
with self.assertRaisesMessage(AssertionError, msg):
|
||||
self.middleware(HttpRequest())
|
||||
|
||||
Reference in New Issue
Block a user