The Mock Library
00:00 Now that you understand what mocking is and why it’s useful for testing, you’re probably wondering how can you use mocks, and you want to write some code and see how this works.
00:11
The Mock
object comes from unittest.mock
, and this is built into Python 3.3 and above. If you’re using a version older than that, then you can just do a pip install mock
.
00:24
It provides the Mock
class, which we’re going to use a lot throughout this course, and it also provides the patch()
method, which is used to patch objects—in other words, create mocks out of real objects.
Become a Member to join the conversation.