summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/modeltests/test_client/models.py10
-rw-r--r--tests/regressiontests/test_client_regress/models.py17
2 files changed, 21 insertions, 6 deletions
diff --git a/tests/modeltests/test_client/models.py b/tests/modeltests/test_client/models.py
index cd3269ee26..4a0c9d2ae0 100644
--- a/tests/modeltests/test_client/models.py
+++ b/tests/modeltests/test_client/models.py
@@ -37,7 +37,7 @@ class ClientTest(TestCase):
# Check some response details
self.assertContains(response, 'This is a test')
self.assertEqual(response.context['var'], u'\xf2')
- self.assertEqual(response.template.name, 'GET Template')
+ self.assertEqual(response.templates[0].name, 'GET Template')
def test_get_post_view(self):
"GET a view that normally expects POSTs"
@@ -45,7 +45,7 @@ class ClientTest(TestCase):
# Check some response details
self.assertEqual(response.status_code, 200)
- self.assertEqual(response.template.name, 'Empty GET Template')
+ self.assertEqual(response.templates[0].name, 'Empty GET Template')
self.assertTemplateUsed(response, 'Empty GET Template')
self.assertTemplateNotUsed(response, 'Empty POST Template')
@@ -55,7 +55,7 @@ class ClientTest(TestCase):
# Check some response details
self.assertEqual(response.status_code, 200)
- self.assertEqual(response.template.name, 'Empty POST Template')
+ self.assertEqual(response.templates[0].name, 'Empty POST Template')
self.assertTemplateNotUsed(response, 'Empty GET Template')
self.assertTemplateUsed(response, 'Empty POST Template')
@@ -69,7 +69,7 @@ class ClientTest(TestCase):
# Check some response details
self.assertEqual(response.status_code, 200)
self.assertEqual(response.context['data'], '37')
- self.assertEqual(response.template.name, 'POST Template')
+ self.assertEqual(response.templates[0].name, 'POST Template')
self.failUnless('Data received' in response.content)
def test_response_headers(self):
@@ -84,7 +84,7 @@ class ClientTest(TestCase):
response = self.client.post("/test_client/raw_post_view/", test_doc,
content_type="text/xml")
self.assertEqual(response.status_code, 200)
- self.assertEqual(response.template.name, "Book template")
+ self.assertEqual(response.templates[0].name, "Book template")
self.assertEqual(response.content, "Blink - Malcolm Gladwell")
def test_redirect(self):
diff --git a/tests/regressiontests/test_client_regress/models.py b/tests/regressiontests/test_client_regress/models.py
index 22b59e54a9..20ed3af82f 100644
--- a/tests/regressiontests/test_client_regress/models.py
+++ b/tests/regressiontests/test_client_regress/models.py
@@ -9,7 +9,7 @@ from django.test import Client, TestCase
from django.test.utils import ContextList
from django.core.urlresolvers import reverse
from django.core.exceptions import SuspiciousOperation
-from django.template import TemplateDoesNotExist, TemplateSyntaxError, Context
+from django.template import TemplateDoesNotExist, TemplateSyntaxError, Context, Template
from django.template import loader
from django.test.client import encode_file
@@ -861,3 +861,18 @@ class RequestHeadersTest(TestCase):
self.assertEquals(response.content, "HTTP_X_ARG_CHECK: Testing 123")
self.assertRedirects(response, '/test_client_regress/check_headers/',
status_code=301, target_status_code=200)
+
+class ResponseTemplateDeprecationTests(TestCase):
+ """
+ Response.template still works backwards-compatibly, but with pending deprecation warning. Refs #12226.
+
+ """
+ def test_response_template_data(self):
+ response = self.client.get("/test_client_regress/request_data/", data={'foo':'whiz'})
+ self.assertEqual(response.template.__class__, Template)
+ self.assertEqual(response.template.name, 'base.html')
+
+ def test_response_no_template(self):
+ response = self.client.get("/test_client_regress/request_methods/")
+ self.assertEqual(response.template, None)
+