Skip to content

Commit 0f210b3

Browse files
committed
Fix stub executable in tests for Windows
On Python 3.12+, `shutil.which()` will not recognize executables which do not match `PATHEXT` even when given an absolute path to an executable. As a result, this stub executable used in a test case fails to be recognized and an unexpected error is emitted.
1 parent 8ff350b commit 0f210b3

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

tests/test_cli_sync.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,12 @@ def test_invalid_pip_version_in_python_executable(
333333
with open(sync.DEFAULT_REQUIREMENTS_FILE, "w") as req_in:
334334
req_in.write("small-fake-a==1.10.0")
335335

336-
custom_executable = tmp_path / "custom_executable"
336+
# a dummy executable on Windows needs to end in `.exe` in order for
337+
# `shutil.which` to find it
338+
executable_name = (
339+
"custom_executable.exe" if os.name == "nt" else "custom_executable"
340+
)
341+
custom_executable = tmp_path / executable_name
337342
custom_executable.write_text("")
338343

339344
custom_executable.chmod(0o700)

0 commit comments

Comments
 (0)