pytest
$ pytest Community Low RiskThe dominant Python testing framework and CLI runner. Gives coding agents concise failure tracebacks via --tb=short -q, test discovery without execution via --collect-only, and structured JUnit XML reports via --junitxml.
pip install pytest Runs Python test suites directly inside the project's virtual environment.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Deterministic exit codes, --collect-only, --tb=short, --color=no, and built-in --junitxml, though JSON output requires a third-party plugin.
--tb=short -q --color=nokeeps output token-efficient- Built-in
--junitxml; native JSON requirespytest-json-report
Local test runner with isolated .pytest_cache/, though executing tests runs arbitrary project code.
- No remote credentials; behavior reflects project test suite
Installable via pip or uvx across macOS, Linux, and Windows in any Python 3 environment.
- Standard PyPI package across all Python platforms
Expressive -k filtering, --lf (last-failed), and -x fail-fast flags save significant iteration time.
--lfand-ktarget failing tests quickly
Mature MIT-licensed Python ecosystem cornerstone maintained by pytest-dev.
- Canonical
pytest-dev/pytestproject
Comprehensive official documentation and detailed --help flag reference.
- Official docs at docs.pytest.org
Security, Auth & Guardrails
No credentials stored; writes optional cache data to .pytest_cache/.
MIT open-source Python package; completely free.
# pytest Agent Rules - Always pass `--tb=short -q --color=no` (and `-x` or `--maxfail=3`) so long tracebacks do not flood context. - Use `pytest --collect-only -q` to verify node IDs before filtering with `-k`.
Agent-Ready Command Recipes
Safe Read-Only Queries
pytest --collect-only -q --color=no
Enumerates discovered test node IDs without running any test code (note module import side effects).
Controlled Writes & Previews
pytest -q --tb=short --color=no -x tests/
Stops at first failure (-x) with compact tracebacks and no ANSI colors.
Strengths for Agents
- +
--lf(last-failed),-x, and--tb=shortmake agent debug loops fast and token-frugal. - +
--collect-only -qlists exact test node IDs for surgical reruns. - + Built-in
--junitxmlprovides structured XML reports without extra plugins.
Caveats & Pitfalls
- ! No built-in
--jsonreporter without installingpytest-json-report. - ! Importing test modules during
--collect-onlystill executes module-level Python code.