Framework Mode - pyproject.toml configuration
Folder Structure
tests/ ├── test_example.py ├── conftest.py src/ ├── app_module.py pyproject.toml README.md
tests/ ├── test_example.py ├── conftest.py src/ ├── app_module.py pyproject.toml README.md
tests/ folder, contains test scripts like test_example.py.conftest.py, reusable setup and teardown code for tests.src/, the main code under test.pyproject.toml holds pytest settings and dependencies.tests/utils/ or src/utils/.The pyproject.toml file centralizes pytest configuration and dependencies.
[tool.pytest.ini_options] minversion = "7.0" addopts = "-ra -q" testpaths = ["tests"] markers = [ "smoke: quick smoke tests", "slow: slow running tests" ] [tool.poetry.dependencies] python = ">=3.12" [tool.poetry.dev-dependencies] pytest = "^7.0" pytest-cov = "^4.0"
This setup defines minimum pytest version, test folder, custom markers, and dependencies.
Use environment variables or separate config files for sensitive data like credentials.
pytest-cov for coverage reports.pyproject.toml or via CLI options.pyproject.toml for easy maintenance.Where in this framework structure would you add a new fixture to initialize a database connection for tests?