Framework Mode - Log level filtering
Folder Structure
project-root/
├── tests/
│ ├── test_example.py
│ └── conftest.py
├── src/
│ └── app_code.py
├── logs/
│ └── test.log
├── pytest.ini
└── requirements.txt
project-root/
├── tests/
│ ├── test_example.py
│ └── conftest.py
├── src/
│ └── app_code.py
├── logs/
│ └── test.log
├── pytest.ini
└── requirements.txt
tests/, contain test cases using pytest.conftest.py manages setup, including log level filtering configuration.src/ holds the main code under test.logs/ stores log files generated during tests.pytest.ini sets pytest options including log level filters.Use pytest.ini to set log level filtering globally for tests. Example:
[pytest]
log_cli = true
log_cli_level = INFO
log_file = logs/test.log
log_file_level = WARNING
This config means:
logs/test.log.In conftest.py, you can add fixtures to customize or override log levels per test if needed.
Logs filtered by level help keep test output clean and focused.
logs/test.log for detailed error investigation.pytest.ini for global settings: Centralize log config for consistency.Where in this folder structure would you add a fixture to change the log level to DEBUG only for a specific test?