diff options
| author | Hasan Ramezani <hasan.r67@gmail.com> | 2020-09-07 13:33:47 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-09-09 09:04:28 +0200 |
| commit | 2808cdc8fb15ad27f83af3e62db69f5ea7ced29e (patch) | |
| tree | 8a2d09cad742e8f839bdb6ce21b6dc1bc2c73e82 /tests/sessions_tests | |
| parent | fc1446073ed9636047c48796cc20772ab60e12b0 (diff) | |
Fixed #31962 -- Made SessionMiddleware raise SessionInterrupted when session destroyed while request is processing.
Diffstat (limited to 'tests/sessions_tests')
| -rw-r--r-- | tests/sessions_tests/tests.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/tests/sessions_tests/tests.py b/tests/sessions_tests/tests.py index 29b58073e1..11adef9d75 100644 --- a/tests/sessions_tests/tests.py +++ b/tests/sessions_tests/tests.py @@ -19,7 +19,9 @@ from django.contrib.sessions.backends.file import SessionStore as FileSession from django.contrib.sessions.backends.signed_cookies import ( SessionStore as CookieSession, ) -from django.contrib.sessions.exceptions import InvalidSessionKey +from django.contrib.sessions.exceptions import ( + InvalidSessionKey, SessionInterrupted, +) from django.contrib.sessions.middleware import SessionMiddleware from django.contrib.sessions.models import Session from django.contrib.sessions.serializers import ( @@ -28,7 +30,7 @@ from django.contrib.sessions.serializers import ( from django.core import management from django.core.cache import caches from django.core.cache.backends.base import InvalidCacheBackendError -from django.core.exceptions import ImproperlyConfigured, SuspiciousOperation +from django.core.exceptions import ImproperlyConfigured from django.http import HttpResponse from django.test import ( RequestFactory, SimpleTestCase, TestCase, ignore_warnings, @@ -746,10 +748,10 @@ class SessionMiddlewareTests(TestCase): "The request's session was deleted before the request completed. " "The user may have logged out in a concurrent request, for example." ) - with self.assertRaisesMessage(SuspiciousOperation, msg): + with self.assertRaisesMessage(SessionInterrupted, msg): # Handle the response through the middleware. It will try to save # the deleted session which will cause an UpdateError that's caught - # and raised as a SuspiciousOperation. + # and raised as a SessionInterrupted. middleware(request) def test_session_delete_on_end(self): |
