Skip to content

Document actual test mocking convention (monkeypatch + unittest.mock)#404

Merged
gbeane merged 1 commit into
mainfrom
chore/test-mocking-convention
Jun 19, 2026
Merged

Document actual test mocking convention (monkeypatch + unittest.mock)#404
gbeane merged 1 commit into
mainfrom
chore/test-mocking-convention

Conversation

@gbeane

@gbeane gbeane commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

CLAUDE.md's Testing section lists pytest-mock as a tool and shows a mocker: MockerFixture example, but pytest-mock is not declared in any pyproject.toml and is not installed — the mocker fixture raises "fixture 'mocker' not found". This aligns the documentation with the actual, already-consistent convention.

Why docs, not the dependency

The codebase already mocks consistently without pytest-mock:

  • 0 of 105 test files use mocker
  • 29 use unittest.mock, 13 use monkeypatch

unittest.mock + the built-in monkeypatch fixture are stdlib / pytest built-ins and already the de-facto standard here. Adopting pytest-mock would mean adding the dep to all 5 workspace test groups and either a mixed convention or a 42-file migration for marginal ergonomic gain. The actual problem was the doc, not a missing tool.

Changes

  • Remove pytest-mock from the Framework & Tools list; add an explicit "Mocking" bullet pointing to monkeypatch + unittest.mock and noting mocker is not available.
  • Rewrite the mocker: MockerFixture example to use unittest.mock.Mock, plus a short monkeypatch.setattr(...) example for patching module-level symbols.

Docs-only; no code or tests affected.

🤖 Generated with Claude Code

@gbeane gbeane merged commit 00af88c into main Jun 19, 2026
5 checks passed
@gbeane gbeane deleted the chore/test-mocking-convention branch June 19, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant