From 59f66933cd9468eec3dc67714f1b686f8dfb1c39 Mon Sep 17 00:00:00 2001 From: "George Y. Kussumoto" Date: Mon, 2 Oct 2017 21:26:00 -0300 Subject: [PATCH] Update documentation example of pytest.skip(allow_module_level=True) --- doc/en/skipping.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/en/skipping.rst b/doc/en/skipping.rst index e6f1bc3c5..2c91bab71 100644 --- a/doc/en/skipping.rst +++ b/doc/en/skipping.rst @@ -57,11 +57,12 @@ by calling the ``pytest.skip(reason)`` function: It is also possible to skip the whole module using ``pytest.skip(reason, allow_module_level=True)`` at the module level: - .. code-block:: python - if not enabled_platform_edge_cases(): - pytest.skip("unsupported platform", allow_module_level=True) + import pytest + + if not pytest.config.getoption("--custom-flag"): + pytest.skip("--custom-flag is missing, skipping tests", allow_module_level=True) The imperative method is useful when it is not possible to evaluate the skip condition during import time.