Skip to content

Commit 5587428

Browse files
authored
feat: Save HTML source to file when tidy validation fails during test (ietf-tools#3646)
Instead of dumping the whole source code to the console.
1 parent 0bbe216 commit 5587428

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

ietf/utils/test_utils.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,13 @@ def get(self, path, *args, skip_verify=False, **extra):
200200
)
201201

202202
if errors:
203-
n = 1
204-
print("\n")
205-
for line in r.content.decode().splitlines():
206-
print(f"{n: 6}: {line}")
207-
n += 1
208-
print(path)
203+
file_name = "error" + re.sub("/", "-", path) + "source.html"
204+
with open(file_name, "w") as src:
205+
src.write(r.content.decode())
206+
print("\nHTML validation error for URL path", path)
207+
print("HTML source saved to", file_name)
208+
print("See AssertionError below for error location in HTML source.")
209+
209210
self.test.maxDiff = None
210211
self.test.assertEqual("", errors)
211212
return r

0 commit comments

Comments
 (0)