From ad28db666e0884b658f5e240c3d7ee1362688ba1 Mon Sep 17 00:00:00 2001 From: Clifford Gama <53076065+cliff688@users.noreply.github.com> Date: Tue, 27 May 2025 23:20:07 +0200 Subject: [PATCH] Removed redundant redefinition of variable in tests/test_utils/tests.py. --- tests/test_utils/tests.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py index 16692500e3..fd0c47a42c 100644 --- a/tests/test_utils/tests.py +++ b/tests/test_utils/tests.py @@ -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"