Skip to content

Commit 37b6c37

Browse files
committed
Fix tests on windows
1 parent 041e10f commit 37b6c37

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
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

+11-1
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ def test_env_finds_the_correct_executables(tmp_dir, manager):
10011001
venv = VirtualEnv(venv_path)
10021002

10031003
assert Path(venv.python).name == expected_executable
1004-
assert Path(venv.pip).name == expected_pip_executable
1004+
assert Path(venv.pip).name.startswith(expected_pip_executable.split(".")[0])
10051005

10061006

10071007
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):
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

@@ -1079,6 +1083,12 @@ def test_env_finds_fallback_executables_for_generic_env(tmp_dir, manager):
10791083
venv._bin_dir.joinpath(expected_pip_executable).unlink()
10801084
expected_pip_executable = default_pip_executable
10811085

1086+
if not venv._bin_dir.joinpath(expected_executable).exists():
1087+
expected_pip_executable = default_executable
1088+
1089+
if not venv._bin_dir.joinpath(expected_pip_executable).exists():
1090+
expected_pip_executable = default_pip_executable
1091+
10821092
venv = GenericEnv(parent_venv.path, child_env=VirtualEnv(child_venv_path))
10831093

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

0 commit comments

Comments
 (0)