金色时刻 · 15:48
让好资源,触手可及
AGENT SKILL

pytest-testing-assistant

pytest-testing-assistant 是面向测试与安全的 Agent Skill,来自 dmitriiweb/extract-emails。查看技能说明、操作步骤与使用约定,并通过原项目了解详细用法。

Write focused pytest tests as standalone functions (one test per function), avoiding test classes.

SKILL.md

下载 MD ↓
namepytest-testing-assistant
descriptionWrite focused pytest tests as standalone functions (one test per function), avoiding test classes.

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 pytest or pytest path/to/test_file.py to scope runs.
  • See references/pytest_rules.md for detailed guidelines and examples.

Workflow

1) Identify behavior
- Target a single function/behavior per test. Name the test after the behavior being validated.

2) 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.

3) Assertions
- Prefer one main assertion; add secondary checks only when they clarify the outcome.
- Include helpful assertion messages or use expressive matchers for readability.

4) Run and iterate
- Run pytest (optionally narrow with paths or -k expressions).
- Refine names and setup for readability and isolation.

Reference

  • references/pytest_rules.md: structure rules, naming patterns, and usage tips.

来源:dmitriiweb/extract-emails · MIT 许可 · 许可原文 · MD 为来源页保存的历史版本