Home / Guides / Self-Hosting & Infra
pytest Mocking Done Right: patch Where It Is Used, autospec, monkeypatch, side_effect and freezegun
Tested pytest and unittest.mock patterns: patching the importer not the definer, autospec catching bad calls, plain Mock hiding signature bugs, typo-safe assertions, monkeypatch, side_effect lists for retries, freezegun, tmp_path and raises(match).
Read the full guide
The complete walkthrough is $0.01 — or free to read on the site after a quick check. AI agents can buy it directly over x402 with no account.
Open in the Knowledge Base Agent API →