Improve Your Tests With the Python Mock Object Library (Summary)
You’ve learned so much about mocking objects using
Now, you’re able to:
Mockto imitate objects in your tests
- Check usage data to understand how you use your objects
- Customize your mock objects’ return values and side effects
patch()objects throughout your codebase
- See and avoid problems with using Python mock objects
You have built a foundation of understanding that will help you build better tests. You can use mocks to gain insights into your code that you would not have been able to get otherwise.
Here’s one last disclaimer: Beware of overusing mock objects! It’s easy to take advantage of the power of Python mock objects and mock so much that you actually decrease the value of your tests.
If you’re interested in learning more about
unittest.mock, then check out its excellent documentation.
Congratulations, you made it to the end of the course! What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment in the discussion section and let us know.
Become a Member to join the conversation.