Skip to content

Commit

Permalink
Better diagnostics in tests in case text not found in response
Browse files Browse the repository at this point in the history
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 committed Oct 28, 2024
1 parent f6ce1fd commit 57807e0
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 57807e0

Please sign in to comment.