Skip to content

Commit b0c7f92

Browse files
authored
Merge pull request #11813 from pytest-dev/backport-11795-to-8.0.x
[8.0.x] Improve assert mod not in mods error message
2 parents 10c8898 + f15aff0 commit b0c7f92

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/_pytest/config/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,12 @@ def _importconftest(
660660
if dirpath in self._dirpath2confmods:
661661
for path, mods in self._dirpath2confmods.items():
662662
if dirpath in path.parents or path == dirpath:
663-
assert mod not in mods
663+
if mod in mods:
664+
raise AssertionError(
665+
f"While trying to load conftest path {str(conftestpath)}, "
666+
f"found that the module {mod} is already loaded with path {mod.__file__}. "
667+
"This is not supposed to happen. Please report this issue to pytest."
668+
)
664669
mods.append(mod)
665670
self.trace(f"loading conftestmodule {mod!r}")
666671
self.consider_conftest(mod, registration_name=conftestpath_plugin_name)

0 commit comments

Comments
 (0)