Skip to content

Commit

Permalink
TST: windows line separator
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrugman authored Sep 20, 2024
1 parent 41e0422 commit 3e40b71
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions tests/test_torchfix.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import subprocess
from pathlib import Path
from torchfix.torchfix import (
Expand Down Expand Up @@ -96,33 +97,33 @@ def test_parse_error_code_str(case, expected):


def test_stderr_suppression(tmp_path):
data = "import torchvision.datasets as datasets\n"
data = f"import torchvision.datasets as datasets{os.linesep}"
data_path = tmp_path / "fixable.py"
data_path.write_text(data)
result = subprocess.run(
["torchfix", "--select", "TOR203", "--fix", str(data_path)],
stderr=subprocess.PIPE,
text=True,
check=True,
check=False,
)
assert (
result.stderr
== "Finished checking 1 files.\nTransformed 1 files successfully.\n"
result.stderr == f"Finished checking 1 files.{os.linesep}"
f"Transformed 1 files successfully.{os.linesep}"
)

data = "import torchvision.datasets as datasets\n"
data = f"import torchvision.datasets as datasets{os.linesep}"
data_path = tmp_path / "fixable.py"
data_path.write_text(data)
result = subprocess.run(
["torchfix", "--select", "TOR203", "--show-stderr", "--fix", str(data_path)],
stderr=subprocess.PIPE,
text=True,
check=True,
check=False,
)
assert (
result.stderr
== f"Executing codemod...\nFailed to determine module name for {data_path}: "
f"'{data_path}' is not in the subpath of '' OR one path is relative and the "
"other is absolute.\nFinished checking 1 files.\nTransformed 1 files "
"successfully.\n"
result.stderr == f"Executing codemod...{os.linesep}"
f"Failed to determine module name for {data_path}: '{data_path}' is not in the "
f"subpath of '' OR one path is relative and the other is absolute.{os.linesep}"
f"Finished checking 1 files.{os.linesep}"
f"Transformed 1 files successfully.{os.linesep}"
)

0 comments on commit 3e40b71

Please sign in to comment.