Skip to content

Commit 307d446

Browse files
committed
Fix windows testcase (path normalization was never tested here...)
1 parent a5e7ea5 commit 307d446

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

mypy/test/testpep561.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,11 @@ def test_pep561(testcase: DataDrivenTestCase) -> None:
145145
output.append(line[len(test_temp_dir + os.sep) :].rstrip("\r\n"))
146146
else:
147147
# Normalize paths so that the output is the same on Windows and Linux/macOS.
148-
line = line.replace(test_temp_dir + os.sep, test_temp_dir + "/")
149-
output.append(line.rstrip("\r\n"))
148+
# Yes, this is naive: replace all slashes preceding first colon, if any.
149+
path, *rest = line.split(":", maxsplit=1)
150+
if rest:
151+
path = path.replace(os.sep, "/")
152+
output.append(":".join([path, *rest]).rstrip("\r\n"))
150153
iter_count = "" if i == 0 else f" on iteration {i + 1}"
151154
expected = testcase.output if i == 0 else testcase.output2.get(i + 1, [])
152155

0 commit comments

Comments
 (0)