mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Removed redundant redefinition of variable in tests/test_utils/tests.py.
Some checks failed
Docs / docs (push) Waiting to run
Docs / blacken-docs (push) Waiting to run
Tests / JavaScript tests (push) Has been cancelled
Linters / flake8 (push) Has been cancelled
Linters / isort (push) Has been cancelled
Linters / black (push) Has been cancelled
Tests / Windows, SQLite, Python 3.13 (push) Has been cancelled
Some checks failed
Docs / docs (push) Waiting to run
Docs / blacken-docs (push) Waiting to run
Tests / JavaScript tests (push) Has been cancelled
Linters / flake8 (push) Has been cancelled
Linters / isort (push) Has been cancelled
Linters / black (push) Has been cancelled
Tests / Windows, SQLite, Python 3.13 (push) Has been cancelled
This commit is contained in:
parent
e29272bbbd
commit
ad28db666e
1 changed files with 10 additions and 10 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue