Skip to content

Commit

Permalink
fix: pytest >=8.1.0 displays no diff for AssertionError with --import…
Browse files Browse the repository at this point in the history
…-mode=importlib(pytest-dev#12659)
  • Loading branch information
a committed Aug 14, 2024
1 parent 9446f02 commit fc236af
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/_pytest/pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import fnmatch
from functools import partial
from importlib.machinery import ModuleSpec
from importlib.machinery import PathFinder
import importlib.util
import itertools
import os
Expand Down Expand Up @@ -817,7 +818,10 @@ def resolve_pkg_root_and_module_name(
if pkg_root is not None:
module_name = compute_module_name(pkg_root, path)
if module_name:
return pkg_root, module_name
spec = PathFinder.find_spec(module_name, [str(pkg_root)])
if spec is not None:
# Verify that pkk_root and module_name are valid before returning(#12659)
return pkg_root, module_name

raise CouldNotResolvePathError(f"Could not resolve for {path}")

Expand Down

0 comments on commit fc236af

Please sign in to comment.