Directory Compare FCRS-1.0 /llms.txt
← Back to Directory

pytest

$ pytest Community Low Risk
pytest-dev · Code & DevOps · MIT · macos / linux / windows

The 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.

FCRS-1.0 Score
87 /100
Good
Medium Confidence
Zero-Friction Install
pip install pytest
CLI vs MCP Decision CLI Only

Runs Python test suites directly inside the project's virtual environment.

Agent-Readiness Checklist

— JSON Output
— Field Filtering
✓ Non-Interactive
— Dry-Run
— Read-Only Mode
✓ NO_COLOR Clean
✓ Self-Describing
— Official SKILL.md

Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.

FCRS-1.0 6-Dimension Breakdown

Agent-Readiness 20 / 25

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=no keeps output token-efficient
  • Built-in --junitxml; native JSON requires pytest-json-report
Trust & Safety 21 / 25

Local test runner with isolated .pytest_cache/, though executing tests runs arbitrary project code.

  • No remote credentials; behavior reflects project test suite
Setup & Portability 14 / 15

Installable via pip or uvx across macOS, Linux, and Windows in any Python 3 environment.

  • Standard PyPI package across all Python platforms
Utility & Efficiency 14 / 15

Expressive -k filtering, --lf (last-failed), and -x fail-fast flags save significant iteration time.

  • --lf and -k target failing tests quickly
Maintenance & Lineage 9 / 10

Mature MIT-licensed Python ecosystem cornerstone maintained by pytest-dev.

  • Canonical pytest-dev/pytest project
Docs & Verifiability 9 / 10

Comprehensive official documentation and detailed --help flag reference.

  • Official docs at docs.pytest.org

Security, Auth & Guardrails

Auth Modes
No Auth
Credential Storage

No credentials stored; writes optional cache data to .pytest_cache/.

Side Effects
Read-Only Local Write
Cost & Quotas

MIT open-source Python package; completely free.

Copyable Guardrail for CLAUDE.md / AGENTS.md
# 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

Discover tests without executing them
pytest --collect-only -q --color=no

Enumerates discovered test node IDs without running any test code (note module import side effects).

Controlled Writes & Previews

Run targeted tests with compact tracebacks
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=short make agent debug loops fast and token-frugal.
  • + --collect-only -q lists exact test node IDs for surgical reruns.
  • + Built-in --junitxml provides structured XML reports without extra plugins.

Caveats & Pitfalls

  • ! No built-in --json reporter without installing pytest-json-report.
  • ! Importing test modules during --collect-only still executes module-level Python code.

Tested Agent Hosts

Claude Code Codex CLI Gemini CLI