Skip to content

docs: clarify stdlib monkeypatch guidance#14486

Open
MukundaKatta wants to merge 1 commit into
pytest-dev:mainfrom
MukundaKatta:codex/document-stdlib-monkeypatching
Open

docs: clarify stdlib monkeypatch guidance#14486
MukundaKatta wants to merge 1 commit into
pytest-dev:mainfrom
MukundaKatta:codex/document-stdlib-monkeypatching

Conversation

@MukundaKatta
Copy link
Copy Markdown

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
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

1 participant