From 5587428ebc3de4712e06306994b6a065069c545b Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Tue, 15 Mar 2022 15:48:13 +0200 Subject: [PATCH] feat: Save HTML source to file when tidy validation fails during test (#3646) Instead of dumping the whole source code to the console. --- ietf/utils/test_utils.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ietf/utils/test_utils.py b/ietf/utils/test_utils.py index b064e6fb7..d5c0f566d 100644 --- a/ietf/utils/test_utils.py +++ b/ietf/utils/test_utils.py @@ -200,12 +200,13 @@ class VerifyingClient(Client): ) if errors: - n = 1 - print("\n") - for line in r.content.decode().splitlines(): - print(f"{n: 6}: {line}") - n += 1 - print(path) + file_name = "error" + re.sub("/", "-", path) + "source.html" + with open(file_name, "w") as src: + src.write(r.content.decode()) + print("\nHTML validation error for URL path", path) + print("HTML source saved to", file_name) + print("See AssertionError below for error location in HTML source.") + self.test.maxDiff = None self.test.assertEqual("", errors) return r