← ClaudeAtlas

mocking-inprocess-pythonlisted

Use when the mocking-strategy-roster resolved (inprocess, Python) — the override mocking strategy that replaces a downstream dependency with an in-process double (respx for httpx, responses for requests, or a hand-written fake passed to the app factory) instead of a Microcks container. Emits mock wiring only; the business TDD cycle stays with the software-engineer lead.
SebastienDegodez/skraft-plugin · ★ 14 · Testing & QA · score 70
Install: claude install-skill SebastienDegodez/skraft-plugin
# Mocking — In-process x Python adapter (override) Replaces a downstream dependency the SUT calls with an in-process double in a pytest integration test. Selected when the operator overrides the Microcks default. Loaded ONLY when `mocking-strategy-roster` resolved `(inprocess, Python)`. When no library is named, the table below is ordered by priority: take the first row that matches the SUT's HTTP client and whose package is already a dev dependency; otherwise the first row that matches the client. **Boundary:** mock wiring + integration-test scaffold only. No business TDD, no Object Calisthenics enforcement, no provider contract verification. ## Libraries (table order = priority, top = highest) | Priority | Library | Fits | Double | |---|---|---|---| | 1 | respx | the SUT calls through `httpx` | `respx.mock(base_url=...)` routes answering at the HTTP layer | | 2 | responses | the SUT calls through `requests` | `responses.RequestsMock()` registered URLs | | 3 | fake | any client behind an application `Protocol` | a hand-written class passed to the app factory | ## Recipe — respx (httpx) ```python # tests/integration/test_{feature}_api.py import httpx import respx from fastapi.testclient import TestClient from {context}.api.app import create_app from {context}.api.composition import build DOWNSTREAM = "https://rates.example.invalid" def test_a_claim_above_the_limit_waits_for_approval() -> None: with respx.mock(base_url=DOWNSTREAM, assert_all_called=True) as down