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 May 8, 2023
1 parent 5ec7648 commit 76c8335
Showing 1 changed file with 44 additions and 11 deletions.
55 changes: 44 additions & 11 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.cache import ArtifactCache
Expand Down Expand Up @@ -69,12 +71,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 @@ -106,7 +134,7 @@
)
def test_parse_dependency_specification(
requirement: str,
specification: DependencySpec,
specification: DependencySpec | Collection[DependencySpec],
mocker: MockerFixture,
artifact_cache: ArtifactCache,
) -> None:
Expand All @@ -119,8 +147,13 @@ def _mock(self: Path) -> bool:

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

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

0 comments on commit 76c8335

Please sign in to comment.