From e9c0b78ba611ec34b650c7e51701a01cd05edd3f Mon Sep 17 00:00:00 2001 From: Hanne Moa Date: Tue, 5 Mar 2024 08:05:47 +0100 Subject: [PATCH] Preserve 500-error in test 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. --- tests/integration/web/crawler_test.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/integration/web/crawler_test.py b/tests/integration/web/crawler_test.py index 13cc39e830..5ed896c276 100644 --- a/tests/integration/web/crawler_test.py +++ b/tests/integration/web/crawler_test.py @@ -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: