Skip to content

Commit 963cfeb

Browse files
committed
Fix tests on windows
1 parent 041e10f commit 963cfeb

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

tests/console/commands/env/test_info.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import pytest
66

7-
from poetry.utils._compat import WINDOWS
87
from poetry.utils.env import MockEnv
98

109

@@ -45,7 +44,7 @@ def test_env_info_displays_complete_info(tester):
4544
base_prefix=str(Path("/base/prefix")),
4645
base_version=".".join(str(v) for v in sys.version_info[:3]),
4746
executable=sys.executable,
48-
base_executable="python" + (".exe" if WINDOWS else ""),
47+
base_executable="python",
4948
)
5049

5150
assert expected == tester.io.fetch_output()

tests/utils/test_env.py

+12
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,10 @@ def test_env_finds_the_correct_executables_for_generic_env(tmp_dir, manager):
10211021
sys.version_info[0], sys.version_info[1], ".exe" if WINDOWS else ""
10221022
)
10231023

1024+
if WINDOWS:
1025+
expected_executable = "python.exe"
1026+
expected_pip_executable = "pip.exe"
1027+
10241028
assert Path(venv.python).name == expected_executable
10251029
assert Path(venv.pip).name == expected_pip_executable
10261030

@@ -1046,13 +1050,15 @@ def test_env_finds_fallback_executables_for_generic_env(tmp_dir, manager):
10461050
if (
10471051
venv._bin_dir.joinpath(expected_executable).exists()
10481052
and venv._bin_dir.joinpath(major_executable).exists()
1053+
or not venv._bin_dir.joinpath(expected_executable).exists()
10491054
):
10501055
venv._bin_dir.joinpath(expected_executable).unlink()
10511056
expected_executable = major_executable
10521057

10531058
if (
10541059
venv._bin_dir.joinpath(expected_executable).exists()
10551060
and venv._bin_dir.joinpath(default_executable).exists()
1061+
or not venv._bin_dir.joinpath(expected_executable).exists()
10561062
):
10571063
venv._bin_dir.joinpath(expected_executable).unlink()
10581064
expected_executable = default_executable
@@ -1079,6 +1085,12 @@ def test_env_finds_fallback_executables_for_generic_env(tmp_dir, manager):
10791085
venv._bin_dir.joinpath(expected_pip_executable).unlink()
10801086
expected_pip_executable = default_pip_executable
10811087

1088+
if not venv._bin_dir.joinpath(expected_executable).exists():
1089+
expected_pip_executable = default_executable
1090+
1091+
if not venv._bin_dir.joinpath(expected_pip_executable).exists():
1092+
expected_pip_executable = default_pip_executable
1093+
10821094
venv = GenericEnv(parent_venv.path, child_env=VirtualEnv(child_venv_path))
10831095

10841096
assert Path(venv.python).name == expected_executable

0 commit comments

Comments
 (0)