From 662fc9c01292176cafb044a3766897a09d090fd6 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Thu, 19 Oct 2023 18:31:45 +0100 Subject: [PATCH] docs --- doc/en/how-to/skipping.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/en/how-to/skipping.rst b/doc/en/how-to/skipping.rst index 1fc6f5e08..2a1c3f23e 100644 --- a/doc/en/how-to/skipping.rst +++ b/doc/en/how-to/skipping.rst @@ -197,6 +197,14 @@ the test. You can also skip based on the version number of a library: The version will be read from the specified module's ``__version__`` attribute. +Sometimes importing a module can fail due to an exception, if you want to +only skip if the module does not exist pass ModuleNotFoundError as the +``exc`` kwarg: + +.. code-block:: python + + docutils = pytest.importorskip("docutils", exc=ModuleNotFoundError) + Summary ~~~~~~~