Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Mock Django test boundaries safely with override_settings, pytest settings, autospecced unittest.mock objects, output/input capture, requests-mock, VCR.py, outbound HTTP blocking, and time-freezing tools. Use when tests need to replace settings, HTTP calls, time, command output, stdin, or external services without broad fragile MagicMock patches.
.claude/skills/hashgraph-online-django-targeted-mocking/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | -3% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 20% | 0% |
| case-09 | ✗→✓ | ▲ Improved | 31% | 0% |
| case-13 | ✗→✓ | ▲ Improved | -54% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 4% | 0% |
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.
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.autospec=True, spec, spec_set, create_autospec, or a small fake object.Mock/MagicMock when the interface matters.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.MagicMock objects that accept typoed attributes and wrong call signatures.Before finishing:
Other measured skills in the registry, with their headline benchmark lift.