Apply suggestions from code review
Co-authored-by: Florian Bruhin <me@the-compiler.org>
This commit is contained in:
parent
f14d78dbef
commit
b59336ac47
|
@ -37,7 +37,7 @@ error so the underlying issue can be fixed.
|
|||
In ``8.2`` the ``exc_type`` parameter has been added, giving users the ability of passing :class:`ModuleNotFoundError`
|
||||
to skip tests only if the module cannot really be found, and not because of some other error.
|
||||
|
||||
Catching only :class:`ModuleNotFoundError` by default (and let other errors propagate) would be the best solution,
|
||||
Catching only :class:`ModuleNotFoundError` by default (and letting other errors propagate) would be the best solution,
|
||||
however for backward compatibility, pytest will keep the existing behavior but raise an warning if:
|
||||
|
||||
1. The captured exception is of type :class:`ImportError`, and:
|
||||
|
|
|
@ -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 type(exc) is ImportError:
|
||||
if warn_on_import_error and not issubclass(exc, ModuleNotFoundError):
|
||||
lines = [
|
||||
"",
|
||||
f"Module '{modname}' was found, but when imported by pytest it raised:",
|
||||
|
|
Loading…
Reference in New Issue