Skip to content

Commit

Permalink
WIP for pytest-dev#9645 (gather opinions)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoddemus committed Feb 13, 2022
1 parent c01a5c1 commit c3731bd
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/_pytest/pathlib.py
Expand Up @@ -603,11 +603,14 @@ def insert_missing_modules(modules: Dict[str, ModuleType], module_name: str) ->
module_parts = module_name.split(".")
while module_name:
if module_name not in modules:
module = ModuleType(
module_name,
doc="Empty module created by pytest's importmode=importlib.",
)
modules[module_name] = module
try:
__import__(module_name)
except ModuleNotFoundError:
module = ModuleType(
module_name,
doc="Empty module created by pytest's importmode=importlib.",
)
modules[module_name] = module
module_parts.pop(-1)
module_name = ".".join(module_parts)

Expand Down

0 comments on commit c3731bd

Please sign in to comment.