Skip to content

Commit 18f19c8

Browse files
committed
test_corpus.py: improve line-wise comparison
1 parent bb23505 commit 18f19c8

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

tests/test_corpus.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,19 @@ def check_expected_files(dir_path: Path):
9393
expected_file = test_dir / f"expected.{rel_path}"
9494
assert expected_file.exists(), f"Expected file not found: {expected_file}"
9595

96-
expected_content = f"[{rel_path}] \n" + expected_file.read_text()
97-
result_content = f"[{rel_path}] \n" + path.read_text()
98-
assert result_content.strip() == expected_content.strip(), \
96+
expected_content = file_to_lines(expected_file, rel_path)
97+
actual_content = file_to_lines(path, rel_path)
98+
assert actual_content == expected_content, \
9999
f"Output does not match expected content for {rel_path}"
100100

101101
check_expected_files(editor.root_path)
102102

103103
except Exception:
104104
editor._failed = True # Mark as failed to preserve temp directory
105105
raise
106+
107+
108+
def file_to_lines(file_path, rel_path):
109+
expected_content = [f"#{i} [{rel_path}]{c}" for i, c in enumerate(file_path.read_text().splitlines())]
110+
return expected_content
111+

0 commit comments

Comments
 (0)