Skip to content

Commit a0d4792

Browse files
committed
Use difflib to print output differences
1 parent d6a9af8 commit a0d4792

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

tests/conftest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
""" conftest.py """
22
import sys
33
import warnings
4+
from difflib import Differ
45
from pathlib import Path
56
from typing import Iterator
67

@@ -59,13 +60,14 @@ def verify_output_str(output: str, filename: str) -> None:
5960
with open(filename, encoding="utf-8") as output_file:
6061
expected = output_file.read()
6162
if output != expected:
62-
print(f"Expected:\n{expected}\nGot:\n{output}")
63+
print("\n".join(Differ().compare(output.splitlines(), expected.splitlines())))
6364
assert output == expected
6465
for category in (ColumnSettings.NUM_PARAMS, ColumnSettings.MULT_ADDS):
6566
assert_sum_column_totals_match(output, category)
6667

6768

6869
def get_column_value_for_row(line: str, offset: int) -> int:
70+
"""Helper function for getting the column totals."""
6971
col_value = line[offset:]
7072
end = col_value.find(" ")
7173
if end != -1:
@@ -80,6 +82,7 @@ def get_column_value_for_row(line: str, offset: int) -> int:
8082

8183

8284
def assert_sum_column_totals_match(output: str, category: ColumnSettings) -> None:
85+
"""Asserts that column totals match the total from the table summary."""
8386
lines = output.replace("=", "").split("\n\n")
8487
header_row = lines[0].strip()
8588
offset = header_row.find(HEADER_TITLES[category])

0 commit comments

Comments
 (0)