Listen "226: pytest-mock : Mocking in pytest"
Episode Synopsis
pytest-mock is currently the #3 pytest plugin. pytest-mock is a wrapper around unittest.mock.In this episode:Why the pytest-mock plugin is awesomeWhat is mocking, patching, and monkey patchingWhat, if any, is the difference between mock, fake, spy, stub. Why we might need these in testingSome history of mock in Python and how mock became unittest.mockFrom unittest.mockpatch.objectpatch.object with autospecusing these as context managerspytest-mock:The mocker fixture Cleanup in teardownUsing mocker.patch, mocker.spy, and mocker.stubWhy it's awesome and why you might want to use it over straight unittest.mockLinks:top pytest plugins listpytest-mock documentationunittest.mockPodcast episode discussing unittest.mock with Michael Foordmonkeypatch
More episodes of the podcast Test & Code
238: So Long, and Thanks for All the Fish
15/08/2025
237: FastAPI Cloud - Sebastián Ramírez
11/08/2025
236: Git Tips for Testing - Adam Johnson
30/07/2025
235: pytest-django - Adam Johnson
22/07/2025
ZARZA We are Zarza, the prestigious firm behind major projects in information technology.