Plugins

So far, we have focused on using mock directly. However, there are many plugins that can help with mocking, such as pytest-mock, which, amongst other things, provides a mocker fixture. One advantage is that the fixture cleans up after itself, so you don’t need to use a with block, as we did in our examples. mocker.spy is also a handy simplification based on wraps and autospec.

There are also some specialised mocking libraries: