11
11
12
12
13
13
if TYPE_CHECKING :
14
+ from collections .abc import Collection
15
+
14
16
from pytest_mock import MockerFixture
15
17
16
18
from poetry .utils .dependency_specification import DependencySpec
68
70
),
69
71
(
70
72
'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
+ ),
77
105
),
78
106
("name (>=3,<4)" , {"name" : "name" , "version" : ">=3,<4" }),
79
107
(
104
132
],
105
133
)
106
134
def test_parse_dependency_specification (
107
- requirement : str , specification : DependencySpec , mocker : MockerFixture
135
+ requirement : str ,
136
+ specification : DependencySpec | Collection [DependencySpec ],
137
+ mocker : MockerFixture ,
108
138
) -> None :
109
139
original = Path .exists
110
140
@@ -115,6 +145,11 @@ def _mock(self: Path) -> bool:
115
145
116
146
mocker .patch ("pathlib.Path.exists" , _mock )
117
147
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
120
155
)
0 commit comments