diff --git a/src/_pytest/outcomes.py b/src/_pytest/outcomes.py index 8749141aa..76d94accd 100644 --- a/src/_pytest/outcomes.py +++ b/src/_pytest/outcomes.py @@ -269,7 +269,7 @@ def importorskip( reason = f"could not import {modname!r}: {exc}" skipped = Skipped(reason, allow_module_level=True) - if warn_on_import_error and not issubclass(exc, ModuleNotFoundError): + if warn_on_import_error and not isinstance(exc, ModuleNotFoundError): lines = [ "", f"Module '{modname}' was found, but when imported by pytest it raised:",