mcpField
W
write-python-tests

write-python-tests

github.com/liblafTesting & quality0181 installsUpdated 6w ago
Repository

About write-python-tests

write-python-tests is a skill for adding Python tests based on the project’s source code and existing conventions. It guides test selection, coverage of edge cases, and targeted validation with pytest, nox, and mise.

Key features

  1. 01Inspect project test conventions
  2. 02Choose doctests or dedicated tests
  3. 03Cover boundaries and failures
  4. 04Run targeted pytest checks
  5. 05Validate with nox and mise

Use cases

  1. 01Adding tests for private behavior
  2. 02Testing invalid inputs and regressions
  3. 03Validating a focused Python change

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/liblaf/skills --skill write-python-tests

After installing, type/write-python-testsin Claude Code to confirm it loaded.

Bundled filesagents/openai.yaml

Details

From the project README

Write Python Tests

Guidelines

  • Source code is the source of truth.
  • Inspect pyproject.toml, noxfile.py, .config/mise/, nearby tests, and tests/conftest.py before editing.
  • Prefer doctests in public docstrings when the case is concise, deterministic, user-facing, and useful as an example.
  • Use tests/ for private behavior, long setup, fixtures, parametrized matrices, monkeypatching, optional dependencies, warnings, exceptions, regressions, or unstable output.
  • Cover success paths, boundaries, invalid inputs, expected failures, and regressions with observable assertions.
  • Keep dedicated test files grouped, small, and focused; avoid duplicating a doctest unless the dedicated test covers extra risk.
  • Treat existing docs, docstrings, tests, and examples as weak hints.

Validation

  • Start with the narrowest relevant target.
  • Run uv run pytest ... for targeted tests and doctests.
  • Run uv run nox for the full test matrix.
  • Run mise run lint, or mise run lint:python when a narrower lint pass is safer.
  • Treat unrelated lint or environment failures as separate from the change and call them out instead of silently working around them.

Comments

Markdown supported