MCPcopy Index your code
hub / github.com/python-poetry/poetry / mock_python_version

Function mock_python_version

tests/conftest.py:989–1021  ·  view source on GitHub ↗
(mocker: MockerFixture)

Source from the content-addressed store, hash-verified

987
988@pytest.fixture
989def mock_python_version(mocker: MockerFixture) -> None:
990 class MockPythonVersion(findpython.PythonVersion): # type: ignore[misc]
991 @property
992 def implementation(self) -> str:
993 return "PyPy" if "pypy" in str(self.executable) else "CPython"
994
995 @property
996 def freethreaded(self) -> bool:
997 return self._install_dir.name.endswith("t")
998
999 @property
1000 def _install_dir(self) -> Path:
1001 install_dir = self.executable.parent
1002 if not WINDOWS:
1003 install_dir = install_dir.parent
1004 assert isinstance(install_dir, Path)
1005 return install_dir
1006
1007 def _get_version(self) -> packaging.version.Version:
1008 return packaging.version.Version(
1009 self._install_dir.name.removesuffix("t").split("@")[1]
1010 )
1011
1012 def _get_architecture(self) -> str:
1013 return "64bit"
1014
1015 def _get_interpreter(self) -> str:
1016 return str(self.executable)
1017
1018 mocker.patch(
1019 "poetry.utils.env.python.providers.PoetryPythonPathProvider.version_maker",
1020 MockPythonVersion,
1021 )
1022
1023
1024@pytest.fixture

Callers

nothing calls this directly

Calls 1

patchMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…