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

specification: make is_same_package_as() commutative and … #325

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 3 additions & 2 deletions src/poetry/core/packages/specification.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ def is_same_package_as(self, other: PackageSpecification) -> bool:
if other.complete_name != self.complete_name:
return False

if self._source_type != other.source_type:
return False

if self._source_type:
if self._source_type != other.source_type:
return False

if (
self._source_url or other.source_url
Expand Down
23 changes: 23 additions & 0 deletions tests/packages/test_specification.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from __future__ import annotations

import pytest

from poetry.core.packages.specification import PackageSpecification


@pytest.mark.parametrize(
"spec1, spec2, expected",
[
(PackageSpecification("a"), PackageSpecification("a"), True),
(PackageSpecification("a", "type1"), PackageSpecification("a", "type1"), True),
(PackageSpecification("a", "type1"), PackageSpecification("a", "type2"), False),
(PackageSpecification("a"), PackageSpecification("a", "type1"), False),
(PackageSpecification("a", "type1"), PackageSpecification("a"), False),
],
)
def test_is_same_package_source_type(
spec1: PackageSpecification,
spec2: PackageSpecification,
expected: bool,
) -> None:
assert spec1.is_same_package_as(spec2) == expected