Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Guides Django tests to mock only external boundaries such as settings, HTTP, time, and command output, using interface-checked tools.
77% 95%+18 ptsof test cases passed
Passed 21 of 22 test cases with the skill, and 17 of 22 without it.
3 of 3 safety checks passed
Not used yet
Mock only at boundaries that are slow, nondeterministic, external, or hard to trigger. Broad mocks can make tests faster while proving less, so prefer framework helpers and interface-checked replacements.
Decide whether mocking is necessary.
Patch where the code under test looks up the dependency.
Prefer specific tools.
override_settings, modify_settings, or pytest-django's settings fixture.io.StringIO, pytest capsys, or command test helpers.requests-mock for hand-authored responses; VCR.py for recorded responses.time-machine or a similar time-specific tool.Make mocks interface-aware.
autospec=True, spec, spec_set, create_autospec, or a small fake object.Mock/MagicMock when the interface matters.Block unexpected outbound HTTP.
Read mocking-patterns.md for concrete patterns.
django.conf.settings.types.SimpleNamespace when only a few attributes are needed.requests-mock for deterministic API responses you control.Skills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.