summaryrefslogtreecommitdiff
path: root/tests/view_tests
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2015-01-08 15:03:43 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2015-01-12 21:01:34 +0100
commita3e783fe11dd25bbf84bfb6201186566ed473506 (patch)
tree1fe6a54ab582e54f6b1f065f2236bfe2185ce254 /tests/view_tests
parent71b7668b75d10589bbbdc7c5ca9ee7a125f91c90 (diff)
Deprecated passing a Context to a generic Template.render.
A deprecation path is required because the return type of django.template.loader.get_template changed during the multiple template engines refactor. test_csrf_token_in_404 was incorrect: it tested the case when the hardcoded template was rendered, and that template doesn't depend on the CSRF token. This commit makes it test the case when a custom template is rendered.
Diffstat (limited to 'tests/view_tests')
-rw-r--r--tests/view_tests/tests/test_defaults.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/tests/view_tests/tests/test_defaults.py b/tests/view_tests/tests/test_defaults.py
index 7b95211a5a..491e1bd562 100644
--- a/tests/view_tests/tests/test_defaults.py
+++ b/tests/view_tests/tests/test_defaults.py
@@ -19,6 +19,16 @@ class DefaultsTests(TestCase):
response = self.client.get(url)
self.assertEqual(response.status_code, 404)
+ @override_settings(TEMPLATES=[{
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
+ 'OPTIONS': {
+ 'loaders': [
+ ('django.template.loaders.locmem.Loader', {
+ '404.html': '{{ csrf_token }}',
+ }),
+ ],
+ },
+ }])
def test_csrf_token_in_404(self):
"""
The 404 page should have the csrf_token available in the context
@@ -26,9 +36,8 @@ class DefaultsTests(TestCase):
# See ticket #14565
for url in self.non_existing_urls:
response = self.client.get(url)
- csrf_token = response.context['csrf_token']
- self.assertNotEqual(str(csrf_token), 'NOTPROVIDED')
- self.assertNotEqual(str(csrf_token), '')
+ self.assertNotEqual(response.content, 'NOTPROVIDED')
+ self.assertNotEqual(response.content, '')
def test_server_error(self):
"The server_error view raises a 500 status"