Skip to content

Commit 24fe4c2

Browse files
committed
tests: ensure forward compatibility with python-poetry/poetry-core#402
1 parent 3804a13 commit 24fe4c2

File tree

1 file changed

+44
-9
lines changed

1 file changed

+44
-9
lines changed

tests/utils/test_dependency_specification.py

+44-9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212

1313
if TYPE_CHECKING:
14+
from collections.abc import Collection
15+
1416
from pytest_mock import MockerFixture
1517

1618
from poetry.utils.dependency_specification import DependencySpec
@@ -68,12 +70,38 @@
6870
),
6971
(
7072
'requests [security,tests] >= 2.8.1, == 2.8.* ; python_version < "2.7"',
71-
{
72-
"name": "requests",
73-
"markers": 'python_version < "2.7"',
74-
"version": ">=2.8.1,<2.9.0",
75-
"extras": ["security", "tests"],
76-
},
73+
( # allow several equivalent versions to make test more robust
74+
{
75+
"name": "requests",
76+
"markers": 'python_version < "2.7"',
77+
"version": ">=2.8.1,<2.9",
78+
"extras": ["security", "tests"],
79+
},
80+
{
81+
"name": "requests",
82+
"markers": 'python_version < "2.7"',
83+
"version": ">=2.8.1,<2.9.0",
84+
"extras": ["security", "tests"],
85+
},
86+
{
87+
"name": "requests",
88+
"markers": 'python_version < "2.7"',
89+
"version": ">=2.8.1,<2.9.dev0",
90+
"extras": ["security", "tests"],
91+
},
92+
{
93+
"name": "requests",
94+
"markers": 'python_version < "2.7"',
95+
"version": ">=2.8.1,<2.9.0.dev0",
96+
"extras": ["security", "tests"],
97+
},
98+
{
99+
"name": "requests",
100+
"markers": 'python_version < "2.7"',
101+
"version": ">=2.8.1,!=2.8.*",
102+
"extras": ["security", "tests"],
103+
},
104+
),
77105
),
78106
("name (>=3,<4)", {"name": "name", "version": ">=3,<4"}),
79107
(
@@ -104,7 +132,9 @@
104132
],
105133
)
106134
def test_parse_dependency_specification(
107-
requirement: str, specification: DependencySpec, mocker: MockerFixture
135+
requirement: str,
136+
specification: DependencySpec | Collection[DependencySpec],
137+
mocker: MockerFixture,
108138
) -> None:
109139
original = Path.exists
110140

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

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

118-
assert not DeepDiff(
119-
parse_dependency_specification(requirement), specification, ignore_order=True
148+
if isinstance(specification, dict):
149+
specification = [specification]
150+
assert any(
151+
not DeepDiff(
152+
parse_dependency_specification(requirement), spec, ignore_order=True
153+
)
154+
for spec in specification
120155
)

0 commit comments

Comments
 (0)