Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/test2ref/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def assert_paths(ref_path: Path, gen_path: Path, excludes: Iterable[str] | None
"""
diff_excludes: Excludes = (*CONFIG["excludes"], *(excludes or []))
try:
cmd = ["diff", "-ru", str(ref_path), str(gen_path)]
cmd = ["diff", "-ru", "--strip-trailing-cr", str(ref_path), str(gen_path)]
for exclude in diff_excludes:
cmd.extend(("--exclude", exclude))
subprocess.run(cmd, check=True, capture_output=True) # noqa: S603
Expand Down
29 changes: 29 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,3 +345,32 @@ def test_regex(tmp_path):
Hello PLANET 3
"""
)


OPEN_NEWLINES = (
None, # System Default
"", # no translation
"\n", # no translation
"\r\n", # windows
)


@mark.parametrize("gen", OPEN_NEWLINES)
@mark.parametrize("ref", OPEN_NEWLINES)
def test_newline(tmp_path, gen, ref):
"""No newline sensitivity."""
ref_path = tmp_path / "ref"
gen_path = tmp_path / "gen"
ref_path.mkdir()
gen_path.mkdir()

with (gen_path / "file.txt").open("w", newline=gen) as file:
file.write("line0\n")
file.write("line1\n")

with (ref_path / "file.txt").open("w", newline=ref) as file:
file.write("line0\n")
file.write("line1\n")

configure(ref_update=False, ref_path=ref_path)
assert_refdata(ref_path, gen_path)