返回顶部
p

pytest-code-reviewpytest代码审查

Reviews pytest test code for async patterns, fixtures, parametrize, and mocking. Use when reviewing test_*.py files, checking async test functions, fixture usage, or mock patterns.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.1.0
安全检测
已通过
118
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

pytest-code-review

技能名称: pytest-code-review

详细描述:

Pytest 代码审查

快速参考

问题类型参考文档
async def test*、AsyncMock、await 模式references/async-testing.md
conftest.py、工厂夹具、作用域、清理
references/fixtures.md | | @pytest.mark.parametrize、DRY 模式 | references/parametrize.md | | AsyncMock 追踪、patch 模式、何时模拟 | references/mocking.md |

审查清单

  • - [ ] 测试函数使用 async def test* 来测试异步代码
  • [ ] 对异步依赖使用 AsyncMock,而非 Mock
  • [ ] 所有异步模拟和协程都被 await 等待
  • [ ] 共享设置使用 conftest.py 中的夹具
  • [ ] 夹具作用域适当(函数、类、模块、会话)
  • [ ] 带 yield 的夹具在 finally 块中有正确的清理
  • [ ] 对相似测试用例使用 @pytest.mark.parametrize
  • [ ] 多个测试函数之间没有重复的测试逻辑
  • [ ] 模拟正确追踪调用(assertcalledoncewith)
  • [ ] patch() 定位正确的位置(在使用处,而非定义处)
  • [ ] 不模拟应被测试的内部实现
  • [ ] 测试隔离(测试之间没有共享的可变状态)

何时加载参考文档

  • - 审查异步测试函数 → async-testing.md
  • 审查夹具或 conftest.py → fixtures.md
  • 审查相似测试用例 → parametrize.md
  • 审查模拟和补丁 → mocking.md

审查问题

  1. 1. 所有异步函数是否都使用 async def test_* 进行测试?
  2. 夹具是否具有适当的作用域和正确的清理?
  3. 相似测试用例能否参数化以减少重复?
  4. 模拟是否追踪调用并在正确的位置使用?

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 pytest-code-review-1776088089 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 pytest-code-review-1776088089 技能

通过命令行安装

skillhub install pytest-code-review-1776088089

下载

⬇ 下载 pytest-code-review v1.1.0(免费)

文件大小: 11.02 KB | 发布时间: 2026-4-14 14:34

v1.1.0 最新 2026-4-14 14:34
pytest-code-review 1.1.0

- Added a detailed review checklist for pytest async tests, fixtures, parametrization, and mocking.
- Introduced clear references for async patterns, fixtures, parametrize, and mocking topics.
- Provided guidance on when to load specific reference materials.
- Included review questions to guide thoughtful code analysis.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部