·pytest-mocking-strategy
</>

pytest-mocking-strategy

掌握 pytest 的模拟策略:何时使用 autospec=True 与手动模拟、异步代码的 AsyncMock 模式、模拟构建器和工厂,以及永远不应该模拟的内容。包括类型安全的模拟创建模式和模拟与真实对象的决策矩阵。 使用时机:使用模拟依赖项创建单元测试,决定是模拟还是使用真实对象,设置测试隔离,使用外部服务边界测试用例,或构建可重用的模拟工厂。

5安装·0热度·@dawiddutoit

安装

$npx skills add https://github.com/dawiddutoit/custom-claude --skill pytest-mocking-strategy

如何安装 pytest-mocking-strategy

通过命令行快速安装 pytest-mocking-strategy AI 技能到你的开发环境

  1. 打开终端: 打开你的终端或命令行工具(如 Terminal、iTerm、Windows Terminal 等)
  2. 运行安装命令: 复制并运行以下命令:npx skills add https://github.com/dawiddutoit/custom-claude --skill pytest-mocking-strategy
  3. 验证安装: 安装完成后,技能将自动配置到你的 AI 编程环境中,可以在 Claude Code、Cursor 或 OpenClaw 中使用

来源:dawiddutoit/custom-claude。

SKILL.md

查看原文

Mocking is essential for unit testing, but over-mocking creates brittle tests that fail on refactoring. This skill provides a comprehensive framework for deciding what to mock, how to mock it safely, and when to use real objects instead.

Use when deciding what to mock in tests with "create mock", "mock external service", "AsyncMock pattern", or "what should I mock".

Do NOT use for domain testing (never mock domain objects), pytest configuration (use pytest-configuration), or test factories (use pytest-test-data-factories). Quick Start

掌握 pytest 的模拟策略:何时使用 autospec=True 与手动模拟、异步代码的 AsyncMock 模式、模拟构建器和工厂,以及永远不应该模拟的内容。包括类型安全的模拟创建模式和模拟与真实对象的决策矩阵。 使用时机:使用模拟依赖项创建单元测试,决定是模拟还是使用真实对象,设置测试隔离,使用外部服务边界测试用例,或构建可重用的模拟工厂。 来源:dawiddutoit/custom-claude。

可引用信息

为搜索与 AI 引用准备的稳定字段与命令。

安装命令
npx skills add https://github.com/dawiddutoit/custom-claude --skill pytest-mocking-strategy
分类
</>开发工具
认证
收录时间
2026-02-25
更新时间
2026-03-11

Browse more skills from dawiddutoit/custom-claude

快速解答

什么是 pytest-mocking-strategy?

掌握 pytest 的模拟策略:何时使用 autospec=True 与手动模拟、异步代码的 AsyncMock 模式、模拟构建器和工厂,以及永远不应该模拟的内容。包括类型安全的模拟创建模式和模拟与真实对象的决策矩阵。 使用时机:使用模拟依赖项创建单元测试,决定是模拟还是使用真实对象,设置测试隔离,使用外部服务边界测试用例,或构建可重用的模拟工厂。 来源:dawiddutoit/custom-claude。

如何安装 pytest-mocking-strategy?

打开你的终端或命令行工具(如 Terminal、iTerm、Windows Terminal 等) 复制并运行以下命令:npx skills add https://github.com/dawiddutoit/custom-claude --skill pytest-mocking-strategy 安装完成后,技能将自动配置到你的 AI 编程环境中,可以在 Claude Code、Cursor 或 OpenClaw 中使用

这个 Skill 的源码在哪?

https://github.com/dawiddutoit/custom-claude