brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
django-targeted-mockingMock 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.
Independent GitHub snapshot · Automated classification · Original documentation governs
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.MagicMock objects that accept typoed attributes and wrong call signatures.Before finishing: