pytest-mocking-strategy
Installation
SKILL.md
Pytest Mocking Strategy
Purpose
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.
When to Use This Skill
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
The golden rule: Mock external boundaries, test the unit in isolation.
from unittest.mock import AsyncMock, create_autospec
import pytest
Related skills