Complete the code to mark the test with a custom marker named 'slow'.
import pytest @pytest.mark.[1] def test_example(): assert 1 + 1 == 2
The custom marker 'slow' is added using @pytest.mark.slow before the test function.
Complete the code to run only tests marked with 'database' using pytest command line option.
pytest -m [1]-m option.To run tests marked with 'database', use pytest -m database.
Fix the error in the code to register a custom marker 'api' in pytest.ini.
[pytest]
markers =
[1]: mark test as API testMarkers in pytest.ini are case-sensitive and should match the marker used in code exactly. The correct marker is 'api'.
Fill both blanks to mark a test with 'integration' and skip it conditionally when a variable is False.
import pytest @pytest.mark.[1] @pytest.mark.skipif(not is_ready, reason='Not ready') def test_integration(): assert True
The test is marked with 'integration' and uses @pytest.mark.skipif to skip conditionally.
Fill all three blanks to define and use a custom marker 'performance' with pytest.mark and run only those tests.
import pytest @pytest.mark.[1] def test_speed(): assert 100 < 200 # Run tests with: pytest -m [2] # Register marker in pytest.ini: #[pytest] #markers = # [3]: mark test as performance test
The custom marker 'performance' is used consistently in code, command line, and pytest.ini registration.