Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix certain hash miss matches in case of non weel installations #7594

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Code review improvements
  • Loading branch information
quantum-byte committed Mar 6, 2023
commit 62d92baf7206a24ea86cdddc4c1765d79f204f73
2 changes: 1 addition & 1 deletion src/poetry/installation/chef.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def _should_prepare(self, archive: Path) -> bool:
def _is_wheel(cls, archive: Path) -> bool:
return archive.suffix == ".whl"

def get_cached_archive_for_link(self, link: Link, strict: bool) -> Path | None:
def get_cached_archive_for_link(self, link: Link, *, strict: bool) -> Path | None:
archives = self.get_cached_archives_for_link(link)
if not archives:
return None
Expand Down
27 changes: 13 additions & 14 deletions tests/installation/test_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@

from httpretty.core import HTTPrettyRequest
from pytest_mock import MockerFixture
from typing_extensions import Self

from poetry.config.config import Config
from poetry.installation.operations.operation import Operation
Expand Down Expand Up @@ -741,7 +740,7 @@ def test_executor_should_write_pep610_url_references_for_editable_directories(
)


@pytest.mark.parametrize("cached", [False, True])
@pytest.mark.parametrize("is_artifact_cached", [False, True])
def test_executor_should_write_pep610_url_references_for_wheel_urls(
tmp_venv: VirtualEnv,
pool: RepositoryPool,
Expand All @@ -750,9 +749,9 @@ def test_executor_should_write_pep610_url_references_for_wheel_urls(
mock_file_downloads: None,
mocker: MockerFixture,
fixture_dir: FixtureDirGetter,
cached: bool,
is_artifact_cached: bool,
):
if cached:
if is_artifact_cached:
link_cached = fixture_dir("distributions") / "demo-0.1.0-py2.py3-none-any.whl"
mocker.patch(
"poetry.installation.chef.Chef.get_cached_archive_for_link",
Expand Down Expand Up @@ -787,7 +786,7 @@ def test_executor_should_write_pep610_url_references_for_wheel_urls(
verify_installed_distribution(tmp_venv, package, expected_url_reference)


@pytest.mark.parametrize("cached", [False, True])
@pytest.mark.parametrize("is_artifact_cached", [False, True])
def test_executor_should_write_pep610_url_references_for_non_wheel_urls(
tmp_venv: VirtualEnv,
pool: RepositoryPool,
Expand All @@ -796,21 +795,21 @@ def test_executor_should_write_pep610_url_references_for_non_wheel_urls(
mock_file_downloads: None,
mocker: MockerFixture,
fixture_dir: FixtureDirGetter,
cached: bool,
is_artifact_cached: bool,
):
if cached:
link_cached = fixture_dir("distributions") / "demo-0.1.0.tar.gz"
original_func = Chef.get_cached_archive_for_link
if is_artifact_cached:
cached_sdist = fixture_dir("distributions") / "demo-0.1.0.tar.gz"
cached_wheel = fixture_dir("distributions") / "demo-0.1.0-py2.py3-none-any.whl"

def mock_get_cached_archive_for_link(self: Self, link: Link, strict: bool):
if link.filename == "demo-0.1.0.tar.gz":
return link_cached
def mock_get_cached_archive_for_link(_: Link, strict: bool):
if strict:
return cached_sdist
else:
return original_func(self, link, strict)
return cached_wheel

mocker.patch(
"poetry.installation.chef.Chef.get_cached_archive_for_link",
new=mock_get_cached_archive_for_link,
side_effect=mock_get_cached_archive_for_link,
)
package = Package(
"demo",
Expand Down