Merge pull request #2808 from georgeyk/allow-module-level-skip

Allow module level skip
This commit is contained in:
Ronny Pfannschmidt
2017-10-12 06:50:53 +02:00
committed by GitHub
6 changed files with 65 additions and 6 deletions
+10
View File
@@ -54,6 +54,16 @@ by calling the ``pytest.skip(reason)`` function:
if not valid_config():
pytest.skip("unsupported configuration")
It is also possible to skip the whole module using
``pytest.skip(reason, allow_module_level=True)`` at the module level:
.. code-block:: python
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.