From 449b9f9aeeaa3a1529d2c29a9a43e87350177559 Mon Sep 17 00:00:00 2001 From: Clifford Gama Date: Fri, 18 Apr 2025 19:55:59 +0200 Subject: Fixed #35728 -- Computed error messages in assertions only on test failures. Performance regression in 1dae65dc63ae84be5002c37b4ddae0b9220e8808. Thanks to Adam Johnson for the report. --- tests/test_utils/tests.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/test_utils') diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py index 494a0ea8d3..37e87aa102 100644 --- a/tests/test_utils/tests.py +++ b/tests/test_utils/tests.py @@ -1083,6 +1083,15 @@ class InHTMLTests(SimpleTestCase): with self.assertRaisesMessage(AssertionError, msg): self.assertNotInHTML("Hello", haystack=haystack) + def test_assert_not_in_html_msg_prefix(self): + haystack = "

Hello

" + msg = ( + "1 != 0 : Prefix: '

Hello

' unexpectedly found in the following " + f"response\n{haystack!r}" + ) + with self.assertRaisesMessage(AssertionError, msg): + self.assertNotInHTML("

Hello

", haystack=haystack, msg_prefix="Prefix") + class JSONEqualTests(SimpleTestCase): def test_simple_equal(self): -- cgit v1.3