Skip to content

Commit

Permalink
Merge pull request #11813 from pytest-dev/backport-11795-to-8.0.x
Browse files Browse the repository at this point in the history
[8.0.x] Improve assert mod not in mods error message
  • Loading branch information
bluetech authored Jan 14, 2024
2 parents 10c8898 + f15aff0 commit b0c7f92
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/_pytest/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,12 @@ def _importconftest(
if dirpath in self._dirpath2confmods:
for path, mods in self._dirpath2confmods.items():
if dirpath in path.parents or path == dirpath:
assert mod not in mods
if mod in mods:
raise AssertionError(
f"While trying to load conftest path {str(conftestpath)}, "
f"found that the module {mod} is already loaded with path {mod.__file__}. "
"This is not supposed to happen. Please report this issue to pytest."
)
mods.append(mod)
self.trace(f"loading conftestmodule {mod!r}")
self.consider_conftest(mod, registration_name=conftestpath_plugin_name)
Expand Down

0 comments on commit b0c7f92

Please sign in to comment.