From dda712c4ffb7cbe8489b200ea60b96d013c706b2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 14 Sep 2022 07:24:50 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/_pytest/pathlib.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/_pytest/pathlib.py b/src/_pytest/pathlib.py index d719b0488..5c92c42c0 100644 --- a/src/_pytest/pathlib.py +++ b/src/_pytest/pathlib.py @@ -623,7 +623,7 @@ def insert_missing_modules(modules: Dict[str, ModuleType], module_name: str) -> # doc="Empty module created by pytest's importmode=importlib.", # ) # modules[module_name] = module - + # Instead of raising ModuleNotFoundError, replace with dummy directly. if not sys.meta_path: module = ModuleType( @@ -631,11 +631,9 @@ def insert_missing_modules(modules: Dict[str, ModuleType], module_name: str) -> doc="Empty module created by pytest's importmode=importlib.", ) modules[module_name] = module - else: + else: importlib.import_module(module_name) - - - + module_parts.pop(-1) module_name = ".".join(module_parts)