Skip to content

Commit

Permalink
Merge pull request #387 from pytest-dev/where-to-patch-link
Browse files Browse the repository at this point in the history
Add "where to patch" link to the docs
  • Loading branch information
nicoddemus committed Oct 13, 2023
2 parents 09f1814 + cec59a0 commit f019696
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/usage.rst
Expand Up @@ -157,3 +157,12 @@ function decorators for mocking unnecessary, so it will emit a warning when used

If you really intend to mock a context manager, ``mocker.patch.context_manager`` exists
which won't issue the above warning.

Where to patch
--------------

A common issue where mocking appears not to be working is patching in the wrong place.

See this `section in the unittest docs <https://docs.python.org/3/library/unittest.mock.html#where-to-patch>`__ which provides a comprehensive explanation.

Also see this excellent blog post: `Why your mock doesn't work <https://nedbatchelder.com/blog/201908/why_your_mock_doesnt_work.html>`__.

0 comments on commit f019696

Please sign in to comment.