diff --git a/tests/utils/test_env.py b/tests/utils/test_env.py index bae2ff55a2f..5e1fb3cdbb9 100644 --- a/tests/utils/test_env.py +++ b/tests/utils/test_env.py @@ -1765,3 +1765,17 @@ def test_fallback_on_detect_active_python( assert active_python is None assert m.call_count == 1 + + +@pytest.mark.skipif(sys.platform != "win32", reason="Windows only") +def test_detect_active_python_with_bat(poetry: Poetry, tmp_path: Path) -> None: + """On Windows pyenv uses batch files for python management.""" + python_wrapper = tmp_path / "python.bat" + wrapped_python = Path(r"C:\SpecialPython\python.exe") + with python_wrapper.open("w") as f: + f.write(f"@echo {wrapped_python}") + os.environ["PATH"] = str(python_wrapper.parent) + os.pathsep + os.environ["PATH"] + + active_python = EnvManager(poetry)._detect_active_python() + + assert active_python == wrapped_python