From 37b6c370f6c8802a129eb1f00b8173693b403b52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Eustace?= Date: Mon, 13 Sep 2021 23:35:25 +0200 Subject: [PATCH] Fix tests on windows --- tests/console/commands/env/test_info.py | 3 +-- tests/utils/test_env.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/console/commands/env/test_info.py b/tests/console/commands/env/test_info.py index 7212004b418..f57960af039 100644 --- a/tests/console/commands/env/test_info.py +++ b/tests/console/commands/env/test_info.py @@ -4,7 +4,6 @@ import pytest -from poetry.utils._compat import WINDOWS from poetry.utils.env import MockEnv @@ -45,7 +44,7 @@ def test_env_info_displays_complete_info(tester): base_prefix=str(Path("/base/prefix")), base_version=".".join(str(v) for v in sys.version_info[:3]), executable=sys.executable, - base_executable="python" + (".exe" if WINDOWS else ""), + base_executable="python", ) assert expected == tester.io.fetch_output() diff --git a/tests/utils/test_env.py b/tests/utils/test_env.py index ded0f16f819..59c15fcc766 100644 --- a/tests/utils/test_env.py +++ b/tests/utils/test_env.py @@ -1001,7 +1001,7 @@ def test_env_finds_the_correct_executables(tmp_dir, manager): venv = VirtualEnv(venv_path) assert Path(venv.python).name == expected_executable - assert Path(venv.pip).name == expected_pip_executable + assert Path(venv.pip).name.startswith(expected_pip_executable.split(".")[0]) def test_env_finds_the_correct_executables_for_generic_env(tmp_dir, manager): @@ -1021,6 +1021,10 @@ def test_env_finds_the_correct_executables_for_generic_env(tmp_dir, manager): sys.version_info[0], sys.version_info[1], ".exe" if WINDOWS else "" ) + if WINDOWS: + expected_executable = "python.exe" + expected_pip_executable = "pip.exe" + assert Path(venv.python).name == expected_executable assert Path(venv.pip).name == expected_pip_executable @@ -1079,6 +1083,12 @@ def test_env_finds_fallback_executables_for_generic_env(tmp_dir, manager): venv._bin_dir.joinpath(expected_pip_executable).unlink() expected_pip_executable = default_pip_executable + if not venv._bin_dir.joinpath(expected_executable).exists(): + expected_pip_executable = default_executable + + if not venv._bin_dir.joinpath(expected_pip_executable).exists(): + expected_pip_executable = default_pip_executable + venv = GenericEnv(parent_venv.path, child_env=VirtualEnv(child_venv_path)) assert Path(venv.python).name == expected_executable