2
2
3
3
from textwrap import dedent
4
4
5
- from cibuildwheel .projectfiles import get_requires_python_str , setup_py_python_requires
5
+ from cibuildwheel ._compat import tomllib
6
+ from cibuildwheel .projectfiles import (
7
+ get_dependency_groups ,
8
+ get_requires_python_str ,
9
+ setup_py_python_requires ,
10
+ )
6
11
7
12
8
13
def test_read_setup_py_simple (tmp_path ):
@@ -23,7 +28,7 @@ def test_read_setup_py_simple(tmp_path):
23
28
)
24
29
25
30
assert setup_py_python_requires (tmp_path .joinpath ("setup.py" ).read_text ()) == "1.23"
26
- assert get_requires_python_str (tmp_path ) == "1.23"
31
+ assert get_requires_python_str (tmp_path , {} ) == "1.23"
27
32
28
33
29
34
def test_read_setup_py_if_main (tmp_path ):
@@ -45,7 +50,7 @@ def test_read_setup_py_if_main(tmp_path):
45
50
)
46
51
47
52
assert setup_py_python_requires (tmp_path .joinpath ("setup.py" ).read_text ()) == "1.23"
48
- assert get_requires_python_str (tmp_path ) == "1.23"
53
+ assert get_requires_python_str (tmp_path , {} ) == "1.23"
49
54
50
55
51
56
def test_read_setup_py_if_main_reversed (tmp_path ):
@@ -67,7 +72,7 @@ def test_read_setup_py_if_main_reversed(tmp_path):
67
72
)
68
73
69
74
assert setup_py_python_requires (tmp_path .joinpath ("setup.py" ).read_text ()) == "1.23"
70
- assert get_requires_python_str (tmp_path ) == "1.23"
75
+ assert get_requires_python_str (tmp_path , {} ) == "1.23"
71
76
72
77
73
78
def test_read_setup_py_if_invalid (tmp_path ):
@@ -89,7 +94,7 @@ def test_read_setup_py_if_invalid(tmp_path):
89
94
)
90
95
91
96
assert not setup_py_python_requires (tmp_path .joinpath ("setup.py" ).read_text ())
92
- assert not get_requires_python_str (tmp_path )
97
+ assert not get_requires_python_str (tmp_path , {} )
93
98
94
99
95
100
def test_read_setup_py_full (tmp_path ):
@@ -115,7 +120,7 @@ def test_read_setup_py_full(tmp_path):
115
120
assert (
116
121
setup_py_python_requires (tmp_path .joinpath ("setup.py" ).read_text (encoding = "utf8" )) == "1.24"
117
122
)
118
- assert get_requires_python_str (tmp_path ) == "1.24"
123
+ assert get_requires_python_str (tmp_path , {} ) == "1.24"
119
124
120
125
121
126
def test_read_setup_py_assign (tmp_path ):
@@ -138,7 +143,7 @@ def test_read_setup_py_assign(tmp_path):
138
143
)
139
144
140
145
assert setup_py_python_requires (tmp_path .joinpath ("setup.py" ).read_text ()) is None
141
- assert get_requires_python_str (tmp_path ) is None
146
+ assert get_requires_python_str (tmp_path , {} ) is None
142
147
143
148
144
149
def test_read_setup_py_None (tmp_path ):
@@ -161,7 +166,7 @@ def test_read_setup_py_None(tmp_path):
161
166
)
162
167
163
168
assert setup_py_python_requires (tmp_path .joinpath ("setup.py" ).read_text ()) is None
164
- assert get_requires_python_str (tmp_path ) is None
169
+ assert get_requires_python_str (tmp_path , {} ) is None
165
170
166
171
167
172
def test_read_setup_py_empty (tmp_path ):
@@ -183,7 +188,7 @@ def test_read_setup_py_empty(tmp_path):
183
188
)
184
189
185
190
assert setup_py_python_requires (tmp_path .joinpath ("setup.py" ).read_text ()) is None
186
- assert get_requires_python_str (tmp_path ) is None
191
+ assert get_requires_python_str (tmp_path , {} ) is None
187
192
188
193
189
194
def test_read_setup_cfg (tmp_path ):
@@ -199,7 +204,7 @@ def test_read_setup_cfg(tmp_path):
199
204
)
200
205
)
201
206
202
- assert get_requires_python_str (tmp_path ) == "1.234"
207
+ assert get_requires_python_str (tmp_path , {} ) == "1.234"
203
208
204
209
205
210
def test_read_setup_cfg_empty (tmp_path ):
@@ -215,7 +220,7 @@ def test_read_setup_cfg_empty(tmp_path):
215
220
)
216
221
)
217
222
218
- assert get_requires_python_str (tmp_path ) is None
223
+ assert get_requires_python_str (tmp_path , {} ) is None
219
224
220
225
221
226
def test_read_pyproject_toml (tmp_path ):
@@ -231,8 +236,10 @@ def test_read_pyproject_toml(tmp_path):
231
236
"""
232
237
)
233
238
)
239
+ with open (tmp_path / "pyproject.toml" , "rb" ) as f :
240
+ pyproject_toml = tomllib .load (f )
234
241
235
- assert get_requires_python_str (tmp_path ) == "1.654"
242
+ assert get_requires_python_str (tmp_path , pyproject_toml ) == "1.654"
236
243
237
244
238
245
def test_read_pyproject_toml_empty (tmp_path ):
@@ -245,5 +252,15 @@ def test_read_pyproject_toml_empty(tmp_path):
245
252
"""
246
253
)
247
254
)
255
+ with open (tmp_path / "pyproject.toml" , "rb" ) as f :
256
+ pyproject_toml = tomllib .load (f )
248
257
249
- assert get_requires_python_str (tmp_path ) is None
258
+ assert get_requires_python_str (tmp_path , pyproject_toml ) is None
259
+
260
+
261
+ def test_read_dep_groups ():
262
+ pyproject_toml = {"dependency-groups" : {"group1" : ["pkg1" , "pkg2" ], "group2" : ["pkg3" ]}}
263
+ assert get_dependency_groups (pyproject_toml ) == ()
264
+ assert get_dependency_groups (pyproject_toml , "group1" ) == ("pkg1" , "pkg2" )
265
+ assert get_dependency_groups (pyproject_toml , "group2" ) == ("pkg3" ,)
266
+ assert get_dependency_groups (pyproject_toml , "group1" , "group2" ) == ("pkg1" , "pkg2" , "pkg3" )
0 commit comments