From 809a18a59c883447c3ac7b8125ee9372a0e6b380 Mon Sep 17 00:00:00 2001 From: Morten Brekkevold Date: Tue, 24 Sep 2024 10:20:59 +0000 Subject: [PATCH] Make webcrawler assertions more legible If there are multiple unreachable or non-validated pages, pytest will eventually truncate the list it prints. This explicitly adds an assertion message that should include the full list of failures, separated by newlines. --- tests/integration/web/crawler_test.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/integration/web/crawler_test.py b/tests/integration/web/crawler_test.py index a411a38b74..0d0e700979 100644 --- a/tests/integration/web/crawler_test.py +++ b/tests/integration/web/crawler_test.py @@ -243,7 +243,9 @@ def test_all_links_should_be_reachable(webcrawler): # No need to fill up the test report files with contents of OK pages print(_content_as_string(page.content)) unreachable.append(f"{page.url} ({page.response})") - assert not unreachable + assert not unreachable, f"{len(unreachable)} unreachable pages:\n" + '\n'.join( + unreachable + ) def _content_as_string(content): @@ -266,7 +268,7 @@ def test_page_should_be_valid_html(webcrawler): print(errors) invalid.append(page.url) - assert not invalid + assert not invalid, f"{len(invalid)} invalid HTML pages:\n" + '\n'.join(invalid) def should_validate(page: Page):