diff --git a/cl/search/tests/tests.py b/cl/search/tests/tests.py index 9c06e7e6e0..1b34ae48ed 100644 --- a/cl/search/tests/tests.py +++ b/cl/search/tests/tests.py @@ -1242,9 +1242,14 @@ def test_disallowed_wildcard_pattern(self) -> None: test_case["search_params"], ) decoded_content = response.content.decode() + tree = html.fromstring(decoded_content) + h2_error_element = tree.xpath('//h2[@class="alt"]')[0] + h2_text_error = "".join( + h2_error_element.xpath(".//text()") + ).strip() self.assertIn( "The query contains a disallowed expensive wildcard pattern", - decoded_content, + h2_text_error, msg=f"Failed on: {test_case['label']}, no disallowed wildcard pattern error.", )