I won't use `monkeypatch` or `pytest-mock`
This title could be clearer and more informative.Try out Clickbait Shieldfor free (5 uses left this month).
A developer explains why they avoid pytest's `monkeypatch` fixture and the `pytest-mock` `mocker` fixture in favor of the context manager form of `mock.patch.object`. Two main problems are covered: poor scope control (patches can leak into other fixtures depending on argument ordering), and a dangerous interaction when mixing monkeypatch fixtures with context-manager-based patching that can corrupt global state and even break pytest internals. Additional gripes include monkeypatch lagging behind unittest.mock in features, and pytest-mock encouraging an anti-pattern of wrapping imports as fixtures to avoid explicit import statements.
•18m watch time
366 Impressions