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.