April 2019
Intermediate to advanced
646 pages
16h 48m
English
py.test provides a simple mechanism to disable some tests upon certain conditions. This is called test skipping, and the pytest package provides the @mark.skipif decorator for that purpose. If a single test function or a whole test class decorator needs to be skipped upon certain conditions, you need to define it with this decorator and some expression that verifies if the expected condition was met. Here is an example from the official documentation that skips running the whole test case class if the test suite is executed on Windows:
import pytest @pytest.mark.skipif( sys.platform == 'win32', reason="does not run on windows" ) class TestPosixCalls: def test_function(self): "will not be setup or run under ...