Skip to content

Commit

Permalink
fix fixture and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
radoering committed Feb 8, 2025
1 parent 79f7eb3 commit 0a0d2ba
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 4 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,10 @@ def implementation(self) -> str:
return "PyPy" if "pypy" in str(self.executable) else "CPython"

def _get_version(self) -> packaging.version.Version:
return packaging.version.Version(self.executable.parent.name.split("@")[1])
install_dir = self.executable.parent
if not WINDOWS:
install_dir = install_dir.parent
return packaging.version.Version(install_dir.name.split("@")[1])

def _get_interpreter(self) -> str:
return str(self.executable)
Expand Down
9 changes: 6 additions & 3 deletions tests/console/commands/python/test_python_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import pytest

from poetry.utils._compat import WINDOWS


if TYPE_CHECKING:
from cleo.testers.command_tester import CommandTester
Expand Down Expand Up @@ -78,10 +80,11 @@ def test_list_poetry_managed(
poetry_lines = [line.strip() for line in lines if "Poetry" in line]

install_dir = config.python_installation_dir.as_posix()
bin_dir = "" if WINDOWS else "bin/"
expected = {
f"3.10.8 PyPy Poetry {install_dir}/pypy@3.10.8/pypy",
f"3.10.8 PyPy Poetry {install_dir}/pypy@3.10.8/python",
f"3.9.1 CPython Poetry {install_dir}/cpython@3.9.1/python",
f"3.10.8 PyPy Poetry {install_dir}/pypy@3.10.8/{bin_dir}pypy",
f"3.10.8 PyPy Poetry {install_dir}/pypy@3.10.8/{bin_dir}python",
f"3.9.1 CPython Poetry {install_dir}/cpython@3.9.1/{bin_dir}python",
}

assert set(poetry_lines) == expected
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/env/python/test_python_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_poetry_python_path_provider(

assert provider

assert provider.paths == [cpython_path, pypy_path]
assert set(provider.paths) == {cpython_path, pypy_path}
assert len(list(provider.find_pythons())) == 3

assert provider.installation_bin_paths(Version.parse("3.9.1"), "cpython") == [
Expand Down

0 comments on commit 0a0d2ba

Please # to comment.