Python Tests with Pytest
技能 已验证 活跃使用 pytest 编写和评估有效的 Python 测试。适用于编写测试、审查测试代码、调试测试失败或改进测试覆盖率时。涵盖测试设计、夹具、参数化、模拟和异步测试。
通过提供使用 pytest 的清晰指南和最佳实践,使开发人员能够编写健壮、可维护且有效的 Python 测试。
功能
- 编写原子且自包含的单元测试
- 利用参数化进行变体测试
- 遵循项目特定的导入和异步测试规则
- 使用内存传输来测试 MCP 交互
- 使用内联快照处理复杂数据结构
- 实现有效的模拟策略
- 编写描述性的测试名称
- 使用 pytest.raises 处理测试错误
使用场景
- 编写使用 pytest 的新 Python 测试时
- 审查现有测试代码的质量和覆盖率时
- 调试失败的 Python 测试时
- 旨在提高整体测试套件可靠性时
非目标
- 编写非 Python 语言的测试
- 提供 pytest 之外的 Python 测试框架
- 在没有开发人员输入的情况下自动化整个测试过程
工作流
- 理解核心测试原则(原子性、自包含性)
- 使用 pytest 约定(函数、参数化)来组织测试
- 应用项目特定的规则(导入、异步)
- 在边界处实现模拟
- 编写描述性的测试名称
- 使用 pytest.raises 处理预期错误
- 使用提供的命令运行测试
实践
- 测试设计
- 代码质量
- 调试
- 测试覆盖率
先决条件
- Python 3.7+
- 已安装 pytest
安装
npx skills add jlowin/fastmcp通过 npx 运行 Vercel skills CLI(skills.sh)— 需要本地安装 Node.js,以及至少一个兼容 skills 的智能体(Claude Code、Cursor、Codex 等)。前提是仓库遵循 agentskills.io 格式。
质量评分
已验证类似扩展
Migrate Validate
100Validate pending migrations for foreign key consistency, rollback safety, and best practices
Semgrep Rule Creator
100Creates custom Semgrep rules for detecting security vulnerabilities, bug patterns, and code patterns. Use when writing Semgrep rules or building custom static analysis detections.
Moyu (摸鱼)
100감지된 과잉 엔지니어링 패턴: (1) 사용자가 명시적으로 요청하지 않은 코드나 파일을 수정할 때 (2) 요청되지 않은 새로운 추상화 계층(클래스, 인터페이스, 팩토리, 래퍼)을 생성할 때 (3) 요청되지 않은 주석, 문서, JSDoc, 타입 주석을 추가할 때 (4) 요청되지 않은 새로운 종속성을 도입할 때 (5) 최소 편집 대신 파일 전체를 다시 작성할 때 (6) diff 범위가 사용자의 요청을 명백히 초과할 때 (7) 사용자가 "너무 많아", "거기는 건드리지 마", "X만 변경해", "간단하게", "그만"과 같은 신호를 보낼 때 (8) 발생할 수 없는 시나리오에 대한 오류 처리, 유효성 검사, 방어적 코드를 추가할 때 (9) 요청되지 않은 테스트, 설정 스캐폴딩, 문서를 생성할 때
Cleanup Cycles
100Detect and untangle circular dependencies. Runs madge/skott (TS), pycycle (Py), or compiler-only checks (Go/Rust). Auto-fixes leaf-extractable cycles; reports core cycles for human review. Use when the user asks to find circular imports, fix dependency cycles, or untangle module graph. Example queries — "find circular imports", "fix dependency cycles", "untangle our module graph", "why is madge complaining".
Definition Of Done
100Mandatory checks to run before completing any task that touches md files or dart code in this repository.
Openclaw Testing
100Choose, run, rerun, or debug OpenClaw tests, CI checks, Docker E2E lanes, release validation, and the cheapest safe verification path.