August 2018
Beginner
160 pages
4h 8m
English
You might have tests that should not be executed unless some condition is met. For example, some tests might depend on certain libraries that are not always installed, or a local database that might not be online, or are executed only on certain platforms.
Pytest provides a built-in mark, skipif, that can be used to skip tests based on specific conditions. Skipped tests are not executed if the condition is true, and are not counted towards test suite failures.
For example, you can use the skipif mark to always skip a test when executing on Windows:
import sysimport pytest@pytest.mark.skipif( sys.platform.startswith("win"), reason="fork not available on Windows",)def test_spawn_server_using_fork(): ...
The first argument ...
Read now
Unlock full access