From 679212a47ac3e22a6fbb6ee3cd4c09f29aae8b5d Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Tue, 3 Oct 2023 09:25:48 +0200 Subject: [PATCH] Refs #34657 -- Made msg_prefix handling in assertURLEqual()/assertInHTML consistent with other assertions. Co-authored-by: Chinmoy Chakraborty --- django/test/testcases.py | 4 ++++ docs/releases/5.1.txt | 4 ++++ tests/test_utils/tests.py | 24 +++++++++++++++++++++++- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/django/test/testcases.py b/django/test/testcases.py index 391b5e99cc..bdb64b3a15 100644 --- a/django/test/testcases.py +++ b/django/test/testcases.py @@ -463,6 +463,8 @@ class SimpleTestCase(unittest.TestCase): (scheme, netloc, path, params, urlencode(query_parts), fragment) ) + if msg_prefix: + msg_prefix += ": " self.assertEqual( normalize(url1), normalize(url2), @@ -880,6 +882,8 @@ class SimpleTestCase(unittest.TestCase): self, haystack, None, "Second argument is not valid HTML:" ) real_count = parsed_haystack.count(parsed_needle) + if msg_prefix: + msg_prefix += ": " if count is not None: self.assertEqual( real_count, diff --git a/docs/releases/5.1.txt b/docs/releases/5.1.txt index bd70a2c7ac..a8f0c32f9b 100644 --- a/docs/releases/5.1.txt +++ b/docs/releases/5.1.txt @@ -254,6 +254,10 @@ Miscellaneous * In order to improve accessibility, the admin's changelist filter is now rendered in a ``