From 3716da74b74689adef9f95487f0d510a4ae45233 Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Tue, 15 Mar 2022 14:54:35 +0200 Subject: [PATCH] feat: Save HTML source to file when tidy validation fails during test 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 b064e6fb775..d5c0f566d6d 100644 --- a/ietf/utils/test_utils.py +++ b/ietf/utils/test_utils.py @@ -200,12 +200,13 @@ def get(self, path, *args, skip_verify=False, **extra): ) 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