Skip to content

Commit

Permalink
Fix comparison failure logging
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-fred committed Dec 11, 2023
1 parent d1f466d commit b72abd7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions tests/integration/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,21 +283,22 @@ def compare_dataframes(generated: pd.DataFrame, expected: pd.DataFrame) -> None:
printerr(f"{col=} {unequal_only_where_null=}")

# let's try and find failing rows by converting to str
MAX_FAILURES_TO_PRINT = 5
MAX_FAILURES_TO_PRINT = 20
failures = 0
for row in range(len(generated)):
gen_str = str(generated[col][row: row + 1].values)
exp_str = str(expected[col][row: row + 1].values)
if gen_str != exp_str:
failures += 1
if failures > MAX_FAILURES_TO_PRINT:
printerr(f"Failures truncated after {MAX_FAILURES_TO_PRINT}")
continue
else:
if failures < MAX_FAILURES_TO_PRINT:
printerr(f">>> FAILURE at {col=}, {row=}: {gen_str} != {exp_str}")
elif failures == MAX_FAILURES_TO_PRINT:
printerr(f"Failures truncated after {MAX_FAILURES_TO_PRINT}...")
else:
continue

if failures > 0:
raise ValueError(f"{failures} row mismatch(es) between tables")
raise ValueError(f"Found {failures} row mismatch(es) between tables")

else:
# None != None according to pandas, and this is responsible for the apparent mismatch
Expand Down

0 comments on commit b72abd7

Please sign in to comment.