0
0
PyTesttesting~10 mins

pytest.ini configuration - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test checks that pytest reads the pytest.ini configuration file correctly and applies the specified markers and options during test execution.

Test Code - PyTest
PyTest
import pytest

@pytest.mark.slow
def test_example():
    assert 1 + 1 == 2

# Run with: pytest -m slow
Execution Trace - 4 Steps
StepActionSystem StateAssertionResult
1Pytest starts and reads pytest.ini configuration filepytest.ini file is present with markers and options definedpytest recognizes the 'slow' marker from pytest.iniPASS
2Pytest collects tests and finds test_example marked with @pytest.mark.slowTest suite includes test_example with 'slow' markerTest is correctly marked as 'slow'PASS
3Pytest runs test_example with marker filter '-m slow'Only tests marked 'slow' are executedtest_example runs and assertion 1 + 1 == 2 passesPASS
4Pytest finishes test run and generates reportReport shows test_example passed with marker 'slow'Test report includes marker info and test passed statusPASS
Failure Scenario
Failing Condition: pytest.ini file missing or marker 'slow' not defined in pytest.ini
Execution Trace Quiz - 3 Questions
Test your understanding
What does pytest.ini configure in this test?
AChanges Python version for tests
BRuns tests in parallel automatically
CDefines the 'slow' marker so pytest recognizes it
DDisables all tests except test_example
Key Result
Always register custom markers in pytest.ini to avoid warnings and ensure pytest recognizes them during test runs.