mirror of
https://github.com/django/django.git
synced 2025-06-09 05:29:13 +00:00
Removed redundant redefinition of variable in tests/test_utils/tests.py.
This commit is contained in:
parent
e29272bbbd
commit
ad28db666e
@ -517,7 +517,7 @@ class AssertTemplateUsedContextManagerTests(SimpleTestCase):
|
||||
with self.assertTemplateNotUsed("template_used/alternative.html"):
|
||||
pass
|
||||
|
||||
def test_error_message(self):
|
||||
def test_error_message_no_template_used(self):
|
||||
msg = "No templates used to render the response"
|
||||
with self.assertRaisesMessage(AssertionError, msg):
|
||||
with self.assertTemplateUsed("template_used/base.html"):
|
||||
@ -527,15 +527,6 @@ class AssertTemplateUsedContextManagerTests(SimpleTestCase):
|
||||
with self.assertTemplateUsed(template_name="template_used/base.html"):
|
||||
pass
|
||||
|
||||
msg2 = (
|
||||
"Template 'template_used/base.html' was not a template used to render "
|
||||
"the response. Actual template(s) used: template_used/alternative.html"
|
||||
)
|
||||
with self.assertRaisesMessage(AssertionError, msg2):
|
||||
with self.assertTemplateUsed("template_used/base.html"):
|
||||
render_to_string("template_used/alternative.html")
|
||||
|
||||
msg = "No templates used to render the response"
|
||||
with self.assertRaisesMessage(AssertionError, msg):
|
||||
response = self.client.get("/test_utils/no_template_used/")
|
||||
self.assertTemplateUsed(response, "template_used/base.html")
|
||||
@ -549,6 +540,15 @@ class AssertTemplateUsedContextManagerTests(SimpleTestCase):
|
||||
template = Template("template_used/alternative.html", name=None)
|
||||
template.render(Context())
|
||||
|
||||
def test_error_message_unexpected_template_used(self):
|
||||
msg = (
|
||||
"Template 'template_used/base.html' was not a template used to render "
|
||||
"the response. Actual template(s) used: template_used/alternative.html"
|
||||
)
|
||||
with self.assertRaisesMessage(AssertionError, msg):
|
||||
with self.assertTemplateUsed("template_used/base.html"):
|
||||
render_to_string("template_used/alternative.html")
|
||||
|
||||
def test_msg_prefix(self):
|
||||
msg_prefix = "Prefix"
|
||||
msg = f"{msg_prefix}: No templates used to render the response"
|
||||
|
Loading…
x
Reference in New Issue
Block a user