Complete the code to mark the test as slow.
import pytest @pytest.mark.[1] def test_example(): assert 1 + 1 == 2
The @pytest.mark.slow marker labels the test as slow, so it can be selected or skipped during test runs.
Complete the code to skip the test when a condition is true.
import pytest @pytest.mark.skipif([1], reason="Not supported") def test_feature(): assert True
The @pytest.mark.skipif(True, reason=...) decorator skips the test unconditionally.
Fix the error in the marker usage to run tests with the 'network' marker only.
# Run tests with pytest -m [1] pytest
The marker name is case-sensitive and should be used without quotes in the command line.
Fill both blanks to mark a test to run only on Linux and skip otherwise.
import pytest import sys @pytest.mark.skipif(sys.platform != [1], reason="Only Linux") def test_linux_only(): assert True # Run with pytest -m [2]
The platform string for Linux is 'linux' (with quotes). The marker name is linux_only to select the test.
Fill all three blanks to create a parametrized test with a marker and skip condition.
import pytest @pytest.mark.[1] @pytest.mark.parametrize("input", [1, 2, 3]) @pytest.mark.skipif(input == [2], reason="Skip input 2") def test_values(input): assert input != 0 # Run tests with pytest -m [3]
The marker name is param. The skip condition checks if input equals 2. The run command uses the same marker name param.