Skip to content

Commit

Permalink
Make webcrawler assertions more legible
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lunkwill42 committed Sep 24, 2024
1 parent 34d019d commit 809a18a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tests/integration/web/crawler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down

0 comments on commit 809a18a

Please sign in to comment.