Skip to content

Commit dd3dd1c

Browse files
committed
fighting with testing windows paths
1 parent 4584886 commit dd3dd1c

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

tests/test_path_finder.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,13 @@ def test_create_python_info():
7474
assert python_info.is_debug is False
7575
assert python_info.company == "PythonCore"
7676
assert python_info.name == "python"
77-
assert python_info.executable == "/usr/bin/python"
77+
# Handle Windows path separators in the executable path
78+
if os.name == "nt":
79+
assert (
80+
python_info.executable.replace("\\", "/") == "/usr/bin/python"
81+
)
82+
else:
83+
assert python_info.executable == "/usr/bin/python"
7884

7985
# Test with non-Python path
8086
with mock.patch(
@@ -281,7 +287,13 @@ def test_which(simple_path_finder):
281287
result = simple_path_finder.which("python")
282288

283289
# Check that we got the correct path
284-
assert result == Path("/usr/bin/python")
290+
if os.name == "nt":
291+
# On Windows, normalize the path for comparison
292+
assert result.as_posix().endswith(
293+
"/usr/bin/python"
294+
) or result.as_posix().endswith("/usr/bin/python.exe")
295+
else:
296+
assert result == Path("/usr/bin/python")
285297

286298
# Test with only_python=True and python executable
287299
simple_path_finder.only_python = True

tests/test_system_finder.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,18 @@ def test_system_finder_initialization():
4141
)
4242

4343
# Check that the paths were added correctly
44-
assert set(p.as_posix() for p in finder.paths) == set(
45-
p.as_posix() for p in paths
46-
)
44+
# On Windows, paths might have drive letters, so we need to normalize
45+
if os.name == "nt":
46+
# Extract just the path part without drive letter for comparison
47+
finder_paths = set(
48+
p.as_posix().split(":", 1)[-1] for p in finder.paths
49+
)
50+
expected_paths = set(p.as_posix().split(":", 1)[-1] for p in paths)
51+
assert finder_paths == expected_paths
52+
else:
53+
assert set(p.as_posix() for p in finder.paths) == set(
54+
p.as_posix() for p in paths
55+
)
4756
assert finder.only_python is True
4857
assert finder.ignore_unsupported is False
4958

0 commit comments

Comments
 (0)