Skip to content

Commit c16b1f7

Browse files
committed
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.
1 parent 34d019d commit c16b1f7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tests/integration/web/crawler_test.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,9 @@ def test_all_links_should_be_reachable(webcrawler):
243243
# No need to fill up the test report files with contents of OK pages
244244
print(_content_as_string(page.content))
245245
unreachable.append(f"{page.url} ({page.response})")
246-
assert not unreachable
246+
assert not unreachable, f"{len(unreachable)} unreachable pages:\n" + '.'.join(
247+
unreachable
248+
)
247249

248250

249251
def _content_as_string(content):
@@ -266,7 +268,7 @@ def test_page_should_be_valid_html(webcrawler):
266268
print(errors)
267269
invalid.append(page.url)
268270

269-
assert not invalid
271+
assert not invalid, f"{len(invalid)} invalid HTML pages:\n" + '.'.join(invalid)
270272

271273

272274
def should_validate(page: Page):

0 commit comments

Comments
 (0)