Framework Mode - pytest.ini configuration
Folder Structure
project-root/ ├── tests/ │ ├── test_example.py │ └── conftest.py ├── src/ │ └── app_code.py ├── pytest.ini └── requirements.txt
project-root/ ├── tests/ │ ├── test_example.py │ └── conftest.py ├── src/ │ └── app_code.py ├── pytest.ini └── requirements.txt
pytest.ini file to set global pytest options and markers.tests/ folder containing test functions.conftest.py for shared setup and teardown code.src/ folder.The pytest.ini file is used to configure pytest behavior globally for the project.
Common configurations include:
Example pytest.ini content:
[pytest]
minversion = 7.0
addopts = -ra -q
testpaths = tests
markers =
smoke: Quick smoke tests
regression: Full regression suite
log_cli = true
log_cli_level = INFO
This setup helps run tests consistently across environments without repeating command line arguments.
pytest.ini can configure reporting options such as verbosity and logging to help understand test results.
For CI/CD pipelines:
addopts to include plugins like pytest-html for HTML reports.pytest.ini for consistent runs.Example snippet for CI usage:
pytest --html=report.html --self-contained-html
Where in this framework structure would you add a new custom marker called slow to categorize tests that take longer to run?