Skip to content

Commit

Permalink
Better diagnostics in tests in case text not found in response (apach…
Browse files Browse the repository at this point in the history
…e#43428)

The assertions during tests checkign if content was in response,
did not print the content of the response, which made it difficult
to diagnose what was wrong with the response.

Adding response in case of failure should help to investigate
issues in CI where those asserts fail.
  • Loading branch information
potiuk authored and ellisms committed Nov 13, 2024
1 parent e114fb3 commit d93406f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests_common/test_utils/www.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ def check_content_in_response(text, resp, resp_code=200):
assert resp_code == resp.status_code
if isinstance(text, list):
for line in text:
assert line in resp_html, f"Couldn't find {line!r}"
assert line in resp_html, f"Couldn't find {line!r}\nThe response was:\n{resp_html!r}"
else:
assert text in resp_html, f"Couldn't find {text!r}"
assert text in resp_html, f"Couldn't find {text!r}\nThe response was:\n{resp_html!r}"


def check_content_not_in_response(text, resp, resp_code=200):
Expand Down

0 comments on commit d93406f

Please sign in to comment.