Skip to content

Commit

Permalink
Preserve 500-error in test
Browse files Browse the repository at this point in the history
On (some?) 500-errors, content Page.content_type does not have the
method "lower", triggering a new exception that makes more of a hassle
finding what caused the 500.

A request that returns with a 500 response-code has no HTML to validate
anyway so let's just bail.
  • Loading branch information
hmpf committed Mar 7, 2024
1 parent 6e728fc commit 90f3652
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tests/integration/web/crawler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,11 @@ def test_page_should_be_valid_html(page):

def should_validate(page: Page):
"""Returns True if page is eligible for HTML validation, False if not"""
if not page.content_type or 'html' not in page.content_type.lower():
if (
page.response == 500
or not page.content_type
or 'html' not in page.content_type.lower()
):
return False
path = normalize_path(page.url)
for blacklisted_path in TIDY_BLACKLIST:
Expand Down

0 comments on commit 90f3652

Please sign in to comment.