Framework Mode - setup.cfg configuration
Folder Structure
project-root/ ├── tests/ │ ├── test_example.py │ └── conftest.py ├── src/ │ └── app_code.py ├── setup.cfg └── pytest.ini (optional)
project-root/ ├── tests/ │ ├── test_example.py │ └── conftest.py ├── src/ │ └── app_code.py ├── setup.cfg └── pytest.ini (optional)
tests/ folder, contains test scripts like test_example.py.conftest.py holds shared setup code and fixtures.src/ folder, the code under test.setup.cfg file configures pytest options and plugins.The setup.cfg file centralizes pytest settings. It helps to:
Example setup.cfg content:
[tool:pytest]
minversion = 7.0
addopts = -ra -q
testpaths = tests
python_files = test_*.py
markers =
smoke: quick smoke tests
slow: slow running tests
This file lives at the project root and is automatically read by pytest.
Use setup.cfg to configure reporting plugins like pytest-cov and pytest-junitxml.
[tool:pytest] addopts = --cov=src --cov-report=term-missing --junitxml=reports/junit.xml
CI/CD pipelines can run pytest with these settings to generate coverage and XML reports for dashboards.
Reports help teams see test results clearly and catch failures early.
setup.cfg to avoid repeating CLI flags.setup.cfg so all team members share the same test setup.conftest.py: Use setup.cfg for config and conftest.py for fixtures and hooks.Where in this framework structure would you add a new marker called regression to label regression tests?