Commit f06d21eb by Sébastien Eustace Committed by GitHub

Fix Poetry reporting a Python incompatibility when there is none (#1707)

parent 06cdc773
...@@ -508,7 +508,7 @@ class EnvManager(object): ...@@ -508,7 +508,7 @@ class EnvManager(object):
) )
supported_python = self._poetry.package.python_constraint supported_python = self._poetry.package.python_constraint
if not supported_python.allows(Version.parse(python_minor)): if not supported_python.allows(Version.parse(python_patch)):
# The currently activated or chosen Python version # The currently activated or chosen Python version
# is not compatible with the Python constraint specified # is not compatible with the Python constraint specified
# for the project. # for the project.
......
...@@ -664,6 +664,42 @@ def test_create_venv_does_not_try_to_find_compatible_versions_with_executable( ...@@ -664,6 +664,42 @@ def test_create_venv_does_not_try_to_find_compatible_versions_with_executable(
assert 0 == m.call_count assert 0 == m.call_count
def test_create_venv_uses_patch_version_to_detect_compatibility(
manager, poetry, config, mocker
):
if "VIRTUAL_ENV" in os.environ:
del os.environ["VIRTUAL_ENV"]
version = Version.parse(".".join(str(c) for c in sys.version_info[:3]))
poetry.package.python_versions = "^{}".format(
".".join(str(c) for c in sys.version_info[:3])
)
venv_name = manager.generate_env_name("simple-project", str(poetry.file.parent))
mocker.patch("sys.version_info", (version.major, version.minor, version.patch + 1))
check_output = mocker.patch(
"poetry.utils._compat.subprocess.check_output",
side_effect=check_output_wrapper(Version.parse("3.6.9")),
)
m = mocker.patch(
"poetry.utils.env.EnvManager.build_venv", side_effect=lambda *args, **kwargs: ""
)
manager.create_venv(NullIO())
assert not check_output.called
m.assert_called_with(
str(
Path(
"/foo/virtualenvs/{}-py{}.{}".format(
venv_name, version.major, version.minor
)
)
),
executable=None,
)
def test_activate_with_in_project_setting_does_not_fail_if_no_venvs_dir( def test_activate_with_in_project_setting_does_not_fail_if_no_venvs_dir(
manager, poetry, config, tmp_dir, mocker manager, poetry, config, tmp_dir, mocker
): ):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment