Framework Mode - Fixture dependencies (fixture using fixture)
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
conftest.py, fixtures can depend on other fixtures to share setup logic.tests/ use fixtures by declaring them as function parameters.src/ folder contains the main application code under test.pytest.ini holds pytest configuration options.Use pytest.ini or tox.ini to configure pytest options like markers and test paths.
Manage environment variables or secrets outside code, e.g., with .env files or CI environment settings.
Fixtures can accept parameters or use pytest_addoption to handle different environments or browsers.
pytest-html or pytest-cov for HTML reports and coverage.pytest --junitxml=report.xml.function, module, or session scopes to optimize test speed.autouse sparingly: Only when you want fixtures to run automatically without explicit use.Where in this folder structure would you add a new fixture that depends on an existing database connection fixture?