Skip to content

Commit

Permalink
Fix tests on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
sdispater committed Sep 13, 2021
1 parent 041e10f commit 963cfeb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 1 addition & 2 deletions tests/console/commands/env/test_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import pytest

from poetry.utils._compat import WINDOWS
from poetry.utils.env import MockEnv


Expand Down Expand Up @@ -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()
Expand Down
12 changes: 12 additions & 0 deletions tests/utils/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -1046,13 +1050,15 @@ def test_env_finds_fallback_executables_for_generic_env(tmp_dir, manager):
if (
venv._bin_dir.joinpath(expected_executable).exists()
and venv._bin_dir.joinpath(major_executable).exists()
or not venv._bin_dir.joinpath(expected_executable).exists()
):
venv._bin_dir.joinpath(expected_executable).unlink()
expected_executable = major_executable

if (
venv._bin_dir.joinpath(expected_executable).exists()
and venv._bin_dir.joinpath(default_executable).exists()
or not venv._bin_dir.joinpath(expected_executable).exists()
):
venv._bin_dir.joinpath(expected_executable).unlink()
expected_executable = default_executable
Expand All @@ -1079,6 +1085,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
Expand Down

0 comments on commit 963cfeb

Please sign in to comment.