Skip to content

Commit 7ef1897

Browse files
committed
pathlib: Fix module path used when using importlib with namespaces
1 parent 5af46f3 commit 7ef1897

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/_pytest/pathlib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ def import_path(
540540
# Try to import this module using the standard import mechanisms, but
541541
# without touching sys.path.
542542
try:
543-
pkg_root, module_name = resolve_pkg_root_and_module_name(
543+
_, module_name = resolve_pkg_root_and_module_name(
544544
path, consider_namespace_packages=consider_namespace_packages
545545
)
546546
except CouldNotResolvePathError:
@@ -551,7 +551,7 @@ def import_path(
551551
return sys.modules[module_name]
552552

553553
mod = _import_module_using_spec(
554-
module_name, path, pkg_root, insert_modules=False
554+
module_name, path, path.parent, insert_modules=False
555555
)
556556
if mod is not None:
557557
return mod

0 commit comments

Comments
 (0)