diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 8f275e4d622..3cadbd039a1 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -1734,8 +1734,16 @@ def parsefactories( if holderobj in self._holderobjseen: return + module_types = (types.ModuleType,) + # support IPython's DummyMod if the module containing it has been imported + if ( + DummyMod := getattr( + sys.modules.get("IPython.core.interactiveshell"), "DummyMod", None + ) + ) is not None: + module_types += (DummyMod,) # Avoid accessing `@property` (and other descriptors) when iterating fixtures. - if not safe_isclass(holderobj) and not isinstance(holderobj, types.ModuleType): + if not safe_isclass(holderobj) and not isinstance(holderobj, module_types): holderobj_tp: object = type(holderobj) else: holderobj_tp = holderobj