Test Overview
This test checks that pytest correctly reads configuration options from setup.cfg file. It verifies that a simple test runs and respects the configured markers and options.
This test checks that pytest correctly reads configuration options from setup.cfg file. It verifies that a simple test runs and respects the configured markers and options.
import pytest def test_example(): assert 1 + 1 == 2 # setup.cfg content: # [tool:pytest] # markers = example_marker: mark test as example # addopts = -v # Run command: # pytest --markers # pytest test_sample.py
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | pytest starts and reads setup.cfg configuration file | pytest loads [tool:pytest] section with markers and addopts | pytest configuration options are loaded successfully | PASS |
| 2 | pytest discovers test_example function in test file | test_example function is found and ready to run | test function is detected by pytest | PASS |
| 3 | pytest runs test_example with verbosity enabled from addopts | test runs with verbose output | assert 1 + 1 == 2 is true | PASS |
| 4 | pytest finishes test run and reports results | test report shows 1 passed test with verbose details | test report matches expected output with configured verbosity | PASS |
setup.cfg file in pytest?setup.cfg file is used to keep pytest settings centralized.setup.cfg.setup.cfg?[pytest] and python_files sets test file patterns.python_files = test_*.py matches typical test files.setup.cfg snippet:[pytest] markers = slow: marks tests as slow python_files = test_*.py
pytest -m slow?slow is defined to label slow tests.-m slow optionpytest -m slow runs only tests marked with @pytest.mark.slow.setup.cfg:[pytest] markers = slow: marks slow tests python_files = test_*.py python_classes = Test* python_functions = test_*
legacy_tests folder without typing command line options. How do you configure setup.cfg to do this?--ignore=folder option tells pytest to skip that folder.addopts = --ignore=legacy_tests runs pytest with this option automatically.Pass the test and this pattern moves unknown