Skip to content
Global sound
Test & Code

Test & Code

226: pytest-mock : Mocking in pytest

· 11 min · Episode 226

Show notes

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 awesome
• What is mocking, patching, and monkey patching
• What, if any, is the difference between mock, fake, spy, stub.
• Why we might need these in testing
• Some history of mock in Python and how mock became unittest.mock
• From unittest.mock
• patch.object
• patch.object with autospec
• using these as context managers

• pytest-mock:
• The mocker fixture
• Cleanup in teardown
• Using mocker.patch, mocker.spy, and mocker.stub
• Why it's awesome…

Website: pythontest.com

Live, last hour: 8,777 songs on 4,888 stations in 124 countries

Discover the world through radio

More ways to discover (9)

Heard something good? Save it, or open it straight away in Spotify.

★ Artist of the week The fastest riser on the radio this week
Your song here? From € 9 per week →
Radio 538 luisteren - Live!Popular right now