Skip to content

Commit b1caefe

Browse files
committed
fixup! Apply meta_hooks on import_module, fixing assertion rewriting
1 parent 9f8163a commit b1caefe

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/_pytest/pathlib.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -400,11 +400,8 @@ def import_module(path, modname=None, ensuresyspath=True):
400400
modname = path.purebasename
401401

402402
for meta_importer in sys.meta_path:
403-
loader = meta_importer.find_module(modname, str(path))
404-
if loader is not None:
405-
spec = importlib.util.spec_from_file_location(
406-
modname, str(path), loader=loader
407-
)
403+
spec = meta_importer.find_spec(modname, [path.dirname])
404+
if spec is not None:
408405
break
409406
else:
410407
spec = importlib.util.spec_from_file_location(modname, str(path))

0 commit comments

Comments
 (0)