1111
1212
1313if TYPE_CHECKING :
14+ from collections .abc import Collection
15+
1416 from pytest_mock import MockerFixture
1517
1618 from poetry .utils .cache import ArtifactCache
6971 ),
7072 (
7173 'requests [security,tests] >= 2.8.1, == 2.8.* ; python_version < "2.7"' ,
72- {
73- "name" : "requests" ,
74- "markers" : 'python_version < "2.7"' ,
75- "version" : ">=2.8.1,<2.9.0" ,
76- "extras" : ["security" , "tests" ],
77- },
74+ ( # allow several equivalent versions to make test more robust
75+ {
76+ "name" : "requests" ,
77+ "markers" : 'python_version < "2.7"' ,
78+ "version" : ">=2.8.1,<2.9" ,
79+ "extras" : ["security" , "tests" ],
80+ },
81+ {
82+ "name" : "requests" ,
83+ "markers" : 'python_version < "2.7"' ,
84+ "version" : ">=2.8.1,<2.9.0" ,
85+ "extras" : ["security" , "tests" ],
86+ },
87+ {
88+ "name" : "requests" ,
89+ "markers" : 'python_version < "2.7"' ,
90+ "version" : ">=2.8.1,<2.9.dev0" ,
91+ "extras" : ["security" , "tests" ],
92+ },
93+ {
94+ "name" : "requests" ,
95+ "markers" : 'python_version < "2.7"' ,
96+ "version" : ">=2.8.1,<2.9.0.dev0" ,
97+ "extras" : ["security" , "tests" ],
98+ },
99+ {
100+ "name" : "requests" ,
101+ "markers" : 'python_version < "2.7"' ,
102+ "version" : ">=2.8.1,!=2.8.*" ,
103+ "extras" : ["security" , "tests" ],
104+ },
105+ ),
78106 ),
79107 ("name (>=3,<4)" , {"name" : "name" , "version" : ">=3,<4" }),
80108 (
106134)
107135def test_parse_dependency_specification (
108136 requirement : str ,
109- specification : DependencySpec ,
137+ specification : DependencySpec | Collection [ DependencySpec ] ,
110138 mocker : MockerFixture ,
111139 artifact_cache : ArtifactCache ,
112140) -> None :
@@ -119,8 +147,13 @@ def _mock(self: Path) -> bool:
119147
120148 mocker .patch ("pathlib.Path.exists" , _mock )
121149
122- assert not DeepDiff (
123- RequirementsParser (artifact_cache = artifact_cache ).parse (requirement ),
124- specification ,
125- ignore_order = True ,
150+ if isinstance (specification , dict ):
151+ specification = [specification ]
152+ assert any (
153+ not DeepDiff (
154+ RequirementsParser (artifact_cache = artifact_cache ).parse (requirement ),
155+ spec ,
156+ ignore_order = True ,
157+ )
158+ for spec in specification
126159 )
0 commit comments