Skip to content

Commit

Permalink
tests: ensure forward compatibility with python-poetry/poetry-core#402
Browse files Browse the repository at this point in the history
  • Loading branch information
radoering committed Apr 30, 2023
1 parent 3804a13 commit 24fe4c2
Showing 1 changed file with 44 additions and 9 deletions.
53 changes: 44 additions & 9 deletions tests/utils/test_dependency_specification.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@


if TYPE_CHECKING:
from collections.abc import Collection

from pytest_mock import MockerFixture

from poetry.utils.dependency_specification import DependencySpec
Expand Down Expand Up @@ -68,12 +70,38 @@
),
(
'requests [security,tests] >= 2.8.1, == 2.8.* ; python_version < "2.7"',
{
"name": "requests",
"markers": 'python_version < "2.7"',
"version": ">=2.8.1,<2.9.0",
"extras": ["security", "tests"],
},
( # allow several equivalent versions to make test more robust
{
"name": "requests",
"markers": 'python_version < "2.7"',
"version": ">=2.8.1,<2.9",
"extras": ["security", "tests"],
},
{
"name": "requests",
"markers": 'python_version < "2.7"',
"version": ">=2.8.1,<2.9.0",
"extras": ["security", "tests"],
},
{
"name": "requests",
"markers": 'python_version < "2.7"',
"version": ">=2.8.1,<2.9.dev0",
"extras": ["security", "tests"],
},
{
"name": "requests",
"markers": 'python_version < "2.7"',
"version": ">=2.8.1,<2.9.0.dev0",
"extras": ["security", "tests"],
},
{
"name": "requests",
"markers": 'python_version < "2.7"',
"version": ">=2.8.1,!=2.8.*",
"extras": ["security", "tests"],
},
),
),
("name (>=3,<4)", {"name": "name", "version": ">=3,<4"}),
(
Expand Down Expand Up @@ -104,7 +132,9 @@
],
)
def test_parse_dependency_specification(
requirement: str, specification: DependencySpec, mocker: MockerFixture
requirement: str,
specification: DependencySpec | Collection[DependencySpec],
mocker: MockerFixture,
) -> None:
original = Path.exists

Expand All @@ -115,6 +145,11 @@ def _mock(self: Path) -> bool:

mocker.patch("pathlib.Path.exists", _mock)

assert not DeepDiff(
parse_dependency_specification(requirement), specification, ignore_order=True
if isinstance(specification, dict):
specification = [specification]
assert any(
not DeepDiff(
parse_dependency_specification(requirement), spec, ignore_order=True
)
for spec in specification
)

0 comments on commit 24fe4c2

Please sign in to comment.