mirror of
https://github.com/django/django.git
synced 2025-09-08 19:50:48 +00:00
Fixed #23300 -- Made assertTemplateUsed throw an error on responses not fetched using the test client.
Thanks zags for the report and bmispelon for the patch.
This commit is contained in:
parent
ca88aa34ad
commit
2d06e3155a
2 changed files with 18 additions and 0 deletions
|
@ -385,6 +385,18 @@ class AssertTemplateUsedContextManagerTests(TestCase):
|
|||
with self.assertTemplateUsed('template_used/base.html'):
|
||||
render_to_string('template_used/alternative.html')
|
||||
|
||||
def test_assert_used_on_http_response(self):
|
||||
response = HttpResponse()
|
||||
error_msg = (
|
||||
'assertTemplateUsed() and assertTemplateNotUsed() are only '
|
||||
'usable on responses fetched using the Django test Client.'
|
||||
)
|
||||
with self.assertRaisesMessage(ValueError, error_msg):
|
||||
self.assertTemplateUsed(response, 'template.html')
|
||||
|
||||
with self.assertRaisesMessage(ValueError, error_msg):
|
||||
self.assertTemplateNotUsed(response, 'template.html')
|
||||
|
||||
|
||||
class HTMLEqualTests(TestCase):
|
||||
def test_html_parser(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue