Skip to content

docs: clarify stdlib monkeypatch guidance#14486

Merged
Pierre-Sassoulas merged 1 commit into
pytest-dev:mainfrom
MukundaKatta:codex/document-stdlib-monkeypatching
May 23, 2026
Merged

docs: clarify stdlib monkeypatch guidance#14486
Pierre-Sassoulas merged 1 commit into
pytest-dev:mainfrom
MukundaKatta:codex/document-stdlib-monkeypatching

Conversation

@MukundaKatta
Copy link
Copy Markdown
Contributor

Document safer patterns for monkeypatching standard library functions:

  • prefer patching the reference used by the code under test
  • prefer explicit dependencies for code users control
  • use MonkeyPatch.context() to keep unavoidable stdlib patches narrowly scoped

Closes #11022

Verification:

  • sphinx-build -W --keep-going -b html doc/en doc/en/_build/html
  • git diff --check

@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label May 15, 2026
@Pierre-Sassoulas Pierre-Sassoulas merged commit b6c4d91 into pytest-dev:main May 23, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document dangers of monkeypatching/mocking stdlib

3 participants