@@ -218,114 +218,52 @@ def test_direct_import(monkeypatch, tmp_path, editable, editable_mode, isolated)
218
218
@pytest .mark .configure
219
219
@pytest .mark .integration
220
220
@pytest .mark .parametrize (
221
- ("editable" , "editable_mode" , "check" ),
221
+ ("editable" , "editable_mode" ),
222
222
[
223
- # Without editable
224
- (False , "" , "isinstance(files(pkg), pathlib.Path)" ),
225
- (False , "" , "any(str(x).endswith('.so') for x in files(pkg).iterdir())" ),
226
- (False , "" , "isinstance(files(pkg.sub_a), pathlib.Path)" ),
227
- (
228
- False ,
229
- "" ,
230
- "any(str(x).endswith('.so') for x in files(pkg.sub_a).iterdir())" ,
231
- ),
232
- (False , "" , "isinstance(files(pkg.sub_b), pathlib.Path)" ),
233
- (
234
- False ,
235
- "" ,
236
- "any(str(x).endswith('.so') for x in files(pkg.sub_b).iterdir())" ,
237
- ),
238
- (False , "" , "isinstance(files(pkg.sub_b.sub_c), pathlib.Path)" ),
239
- (
240
- False ,
241
- "" ,
242
- "any(str(x).endswith('.so') for x in files(pkg.sub_b.sub_c).iterdir())" ,
243
- ),
244
- (False , "" , "isinstance(files(pkg.sub_b.sub_d), pathlib.Path)" ),
245
- (
246
- False ,
247
- "" ,
248
- "any(str(x).endswith('.so') for x in files(pkg.sub_b.sub_d).iterdir())" ,
249
- ),
250
- # Editable redirect
251
- (True , "redirect" , "isinstance(files(pkg), pathlib.Path)" ),
252
- pytest .param (
253
- True ,
254
- "redirect" ,
255
- "any(str(x).endswith('.so') for x in files(pkg).iterdir())" ,
256
- marks = pytest .mark .xfail ,
257
- ),
258
- (True , "redirect" , "isinstance(files(pkg.sub_a), pathlib.Path)" ),
259
- pytest .param (
260
- True ,
261
- "redirect" ,
262
- "any(str(x).endswith('.so') for x in files(pkg.sub_a).iterdir())" ,
263
- marks = pytest .mark .xfail ,
264
- ),
265
- (True , "redirect" , "isinstance(files(pkg.sub_b), pathlib.Path)" ),
266
- pytest .param (
267
- True ,
268
- "redirect" ,
269
- "any(str(x).endswith('.so') for x in files(pkg.sub_b).iterdir())" ,
270
- marks = pytest .mark .xfail ,
271
- ),
272
- (True , "redirect" , "isinstance(files(pkg.sub_b.sub_c), pathlib.Path)" ),
223
+ (False , "" ),
273
224
pytest .param (
274
225
True ,
275
226
"redirect" ,
276
- "any(str(x).endswith('.so') for x in files(pkg.sub_b.sub_c).iterdir())" ,
277
227
marks = pytest .mark .xfail ,
278
228
),
279
- (True , "redirect" , "isinstance(files(pkg.sub_b.sub_d), pathlib.Path)" ),
280
- pytest .param (
281
- True ,
282
- "redirect" ,
283
- "any(str(x).endswith('.so') for x in files(pkg.sub_b.sub_d).iterdir())" ,
284
- marks = pytest .mark .xfail ,
285
- ),
286
- # Editable inplace
287
- (True , "inplace" , "isinstance(files(pkg), pathlib.Path)" ),
288
- (True , "inplace" , "any(str(x).endswith('.so') for x in files(pkg).iterdir())" ),
289
- (True , "inplace" , "isinstance(files(pkg.sub_a), pathlib.Path)" ),
290
- (
291
- True ,
292
- "inplace" ,
293
- "any(str(x).endswith('.so') for x in files(pkg.sub_a).iterdir())" ,
294
- ),
295
- (True , "inplace" , "isinstance(files(pkg.sub_b), pathlib.Path)" ),
296
- (
297
- True ,
298
- "inplace" ,
299
- "any(str(x).endswith('.so') for x in files(pkg.sub_b).iterdir())" ,
300
- ),
301
- (True , "inplace" , "isinstance(files(pkg.sub_b.sub_c), pathlib.Path)" ),
302
- (
303
- True ,
304
- "inplace" ,
305
- "any(str(x).endswith('.so') for x in files(pkg.sub_b.sub_c).iterdir())" ,
306
- ),
307
- (True , "inplace" , "isinstance(files(pkg.sub_b.sub_d), pathlib.Path)" ),
308
- (
309
- True ,
310
- "inplace" ,
311
- "any(str(x).endswith('.so') for x in files(pkg.sub_b.sub_d).iterdir())" ,
312
- ),
229
+ (True , "inplace" ),
313
230
],
314
231
)
315
- def test_importlib_resources (
316
- monkeypatch , tmp_path , editable , editable_mode , isolated , check
317
- ):
232
+ def test_importlib_resources (monkeypatch , tmp_path , editable , editable_mode , isolated ):
318
233
_setup_package_for_editable_layout_tests ( # type: ignore[no-untyped-call]
319
234
monkeypatch , tmp_path , editable , editable_mode , isolated
320
235
)
321
236
isolated .execute (
322
237
textwrap .dedent (
323
- f"""
238
+ """
239
+ from importlib import import_module
324
240
from importlib.resources import files
325
- from importlib.readers import MultiplexedPath
326
- import pkg
327
- import pathlib
328
- assert { check }
241
+ from pathlib import Path
242
+
243
+ def is_extension(path):
244
+ for ext in (".so", ".pyd"):
245
+ if ext in path.suffixes:
246
+ return True
247
+ return False
248
+
249
+ def check_pkg(pkg_name):
250
+ try:
251
+ pkg = import_module(pkg_name)
252
+ pkg_root = files(pkg)
253
+ print(f"pkg_root: [{type(pkg_root)}] {pkg_root}")
254
+ pkg_files = list(pkg_root.iterdir())
255
+ for path in pkg_files:
256
+ print(f"path: [{type(path)}] {path}")
257
+ assert any(is_extension(path) for path in pkg_files if isinstance(path, Path))
258
+ except Exception as err:
259
+ msg = f"Failed in {str(pkg)}"
260
+ raise RuntimeError(msg) from err
261
+
262
+ check_pkg("pkg")
263
+ check_pkg("pkg.sub_a")
264
+ check_pkg("pkg.sub_b")
265
+ check_pkg("pkg.sub_b.sub_c")
266
+ check_pkg("pkg.sub_b.sub_d")
329
267
"""
330
268
)
331
269
)
0 commit comments