summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSergey Kolosov <m17.admin@gmail.com>2016-04-02 16:11:47 +0200
committerTim Graham <timograham@gmail.com>2016-04-04 07:48:48 -0400
commit21dd98a38660747c781802afca7ca02407964383 (patch)
treeb045713969b238a5ea80ceba819e5402b1bb104d /tests
parent5faf745999caa3d2588979ae1262cc28652c21a5 (diff)
Fixed #25699 -- Allowed using the test client if 'django.contrib.sessions' isn't in INSTALLED_APPS.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_client/tests.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/test_client/tests.py b/tests/test_client/tests.py
index 43f6d84a65..5c3735601f 100644
--- a/tests/test_client/tests.py
+++ b/tests/test_client/tests.py
@@ -348,6 +348,13 @@ class ClientTest(TestCase):
self.assertEqual(response.status_code, 200)
self.assertEqual(response.context['user'].username, 'testclient')
+ @override_settings(
+ INSTALLED_APPS=['django.contrib.auth'],
+ SESSION_ENGINE='django.contrib.sessions.backends.file',
+ )
+ def test_view_with_login_when_sessions_app_is_not_installed(self):
+ self.test_view_with_login()
+
def test_view_with_force_login(self):
"Request a page that is protected with @login_required"
# Get the page without logging in. Should result in 302.
@@ -590,6 +597,21 @@ class ClientTest(TestCase):
# Check that the session was modified
self.assertEqual(self.client.session['tobacconist'], 'hovercraft')
+ @override_settings(
+ INSTALLED_APPS=[],
+ SESSION_ENGINE='django.contrib.sessions.backends.file',
+ )
+ def test_sessions_app_is_not_installed(self):
+ self.test_session_modifying_view()
+
+ @override_settings(
+ INSTALLED_APPS=[],
+ SESSION_ENGINE='django.contrib.sessions.backends.nonexistent',
+ )
+ def test_session_engine_is_invalid(self):
+ with self.assertRaisesMessage(ImportError, 'nonexistent'):
+ self.test_session_modifying_view()
+
def test_view_with_exception(self):
"Request a page that is known to throw an error"
with self.assertRaises(KeyError):