django-targeted-mocking

Installation
SKILL.md

Django Targeted Mocking

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.

Boundary Workflow

  1. Decide whether mocking is necessary.

    • Prefer real code for local domain logic.
    • Mock external HTTP, time, settings, output/input, and expensive service edges.
  2. Patch where the code under test looks up the dependency.

    • Patch the imported symbol used by the module under test, not the original library path unless that is what the module reads.
  3. Prefer specific tools.

    • Settings: override_settings, modify_settings, or pytest-django's settings fixture.
    • Output: io.StringIO, pytest capsys, or command test helpers.
    • HTTP: requests-mock for hand-authored responses; VCR.py for recorded responses.
    • Time: pass time as a parameter when possible; otherwise use time-machine or a similar time-specific tool.
Installs
45
Repository
lvtd-llc/skills
GitHub Stars
1
First Seen
Jun 21, 2026
django-targeted-mocking — lvtd-llc/skills