Agent skill
pytest-testing-assistant
Write focused pytest tests as standalone functions (one test per function), avoiding test classes.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/development/pytest-testing-assistant
SKILL.md
Pytest Testing Assistant
Quick start
- Write tests as plain functions; do not use test classes. Aim for one focused test per function/behavior.
- Use clear names:
test_<function>_<behavior>; keep AAA (arrange/act/assert) obvious. - Prefer one primary assertion per test; add minimal supporting checks when necessary.
- Use fixtures sparingly to keep tests readable; favor in-test setup when simple.
- Run with
pytestorpytest path/to/test_file.pyto scope runs. - See
references/pytest_rules.mdfor detailed guidelines and examples.
Workflow
-
Identify behavior
- Target a single function/behavior per test. Name the test after the behavior being validated.
-
Write the test
- Use a standalone function
def test_<thing>():(no classes). - Keep a clear arrange/act/assert structure; avoid hidden work in fixtures unless it improves clarity.
- Use parametrization for small input/output matrices instead of loops.
- Use a standalone function
-
Assertions
- Prefer one main assertion; add secondary checks only when they clarify the outcome.
- Include helpful assertion messages or use expressive matchers for readability.
-
Run and iterate
- Run
pytest(optionally narrow with paths or-kexpressions). - Refine names and setup for readability and isolation.
- Run
Reference
references/pytest_rules.md: structure rules, naming patterns, and usage tips.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?