From 30dcb122ed28af54b1a93324600d6402910e120f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20D=C3=B6ring?= <30527984+radoering@users.noreply.github.com> Date: Fri, 7 Apr 2023 14:06:42 +0200 Subject: [PATCH] add test --- tests/utils/test_env.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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