diff --git a/src/_pytest/outcomes.py b/src/_pytest/outcomes.py index e2a816f585..980cfe6de6 100644 --- a/src/_pytest/outcomes.py +++ b/src/_pytest/outcomes.py @@ -225,7 +225,7 @@ def importorskip( warnings.simplefilter("ignore") try: __import__(modname) - except ImportError as exc: + except ModuleNotFoundError as exc: if reason is None: reason = f"could not import {modname!r}: {exc}" raise Skipped(reason, allow_module_level=True) from None