Complete the code to skip the test unconditionally.
import pytest @pytest.mark.[1]() def test_example(): assert 1 == 1
The @pytest.mark.skip() marker skips the test unconditionally.
Complete the code to skip the test only if Python version is less than 3.8.
import pytest import sys @pytest.mark.[1](sys.version_info < (3, 8)) def test_feature(): assert True
The @pytest.mark.skipif(condition) marker skips the test only if the condition is true.
Fix the error in the code to mark the test as expected to fail.
import pytest @pytest.mark.[1]() def test_buggy(): assert 1 == 2
The @pytest.mark.xfail() marker marks the test as expected to fail.
Fill both blanks to skip the test if the platform is Windows and mark it as expected to fail otherwise.
import pytest import sys @pytest.mark.[1](sys.platform == 'win32') @pytest.mark.[2](sys.platform != 'win32') def test_platform(): assert False
skip which can't be conditionalskip and skipif incorrectlyUse @pytest.mark.skipif(sys.platform == 'win32') to skip on Windows, and @pytest.mark.xfail(sys.platform != 'win32') to mark expected failure otherwise. The skipif takes precedence if its condition is true.
Fill the blanks to skip the test if Python version is less than 3.7, xfail if on Linux, and run normally otherwise.
import pytest import sys import platform @pytest.mark.[1](sys.version_info < (3, 7)) @pytest.mark.[2](platform.system() == 'Linux') def test_conditions(): assert True
xfailifskip instead of skipif for version checkUse @pytest.mark.skipif(sys.version_info < (3, 7)) to skip if Python < 3.7, and @pytest.mark.xfail(platform.system() == 'Linux') to xfail on Linux. Runs normally if Python ≥ 3.7 and not Linux.