pytest¶
The standard testing framework for Python. Scrutin auto-detects pytest when a pyproject.toml (or setup.py/setup.cfg) is present alongside a tests/ or test/ directory, or test_*.py files at the project root.
Installing pytest¶
pytest is not shipped with Scrutin. Follow the upstream install instructions at docs.pytest.org.
Directory structure¶
myproject/
├── pyproject.toml
├── src/
│ └── myproject/
│ ├── __init__.py
│ └── math.py
└── tests/
└── test_math.py
Minimal example¶
src/myproject/math.py
tests/test_math.py
Running¶
Configuration¶
No configuration is required. To override defaults in .scrutin/config.toml:
Virtual environment¶
Scrutin auto-detects your Python virtual environment per suite. Detection order:
[python].interpreterin.scrutin/config.toml[python].venvin.scrutin/config.toml$VIRTUAL_ENVenvironment variable.venv/orvenv/under the suite root (which equals the project root for single-package layouts; in a monorepo with[[suite]] root = "python", this findspython/.venv)$CONDA_PREFIXenvironment variablepython3on$PATH(orpythonon Windows)
Override in config:
Extra pytest flags¶
Pass arbitrary flags through to pytest.main() via [pytest] extra_args. Appended verbatim to every invocation, letting you reach for obscure pytest knobs without Scrutin growing a CLI option for each one:
Custom runner¶
scrutin init writes the default runner to .scrutin/runners/scrutin_pytest.py (the scrutin_ prefix avoids the runner shadowing import pytest from inside itself). Edit that file in place: the engine picks it up automatically whenever it exists. To point at a different path, set runner on an explicit suite: