Video description
Review the main features of the unittest.mock module with a big dive into how to use it effectively and avoid most of the mistakes beginner and intermediate users fall into when using it. The video includes why mocks are needed, how to use them, and how they work; how to patch code to isolate it from internal dependencies; and different kinds of mocks that fit different scenarios.
You will see all this and the common pitfalls with a series of code examples, stepping through the not so well know features of unittest.mock, some of them added only in Python 3.7, that make this library even more powerful.
What You Will Learn
- See why testing doubles are needed
- Create testing doubles with unittest.mock while using the library
- Understand how patches works
Who This Video Is For
People that have used Python and unittest before but aren’t experienced with unittest.mock.
Table of contents
- Introduction 00:01:01
- Creating and Using Mocks 00:04:30
- Testing Doubles 00:04:30
- Using Unittest.mock 00:08:29
- Creating Complex Mocks 00:06:25
- Validating Calls 00:06:56
- Cresting Spies 00:04:07
- Restricted 00:10:07
- Patching Internal Dependencies 00:07:07
- Patch 00:07:07
- Understanding Patch 00:09:43
- Patching Objects and Dicts 00:10:36
- Other Ways to Patch 00:06:49
- Mock and Pytest 00:07:02
Product information
- Title: Understanding Unittest.Mock
- Author(s):
- Release date: January 2019
- Publisher(s): Apress
- ISBN: 9781484244135
You might also like
video
Python Beyond The Basics - Object Oriented Programming
In this Python Beyond the Basics - Object-Oriented Programming training course, expert author David Blaikie will …
video
Modern Python LiveLessons: Big Ideas and Little Code in Python
Overview Modern Python LiveLessons: Big Ideas and Little Code in Python provides developers with an approach …
book
Practices of the Python Pro
Practices of the Python Pro teaches you to design and write professional-quality software that’s understandable, maintainable, …
book
Python Testing with pytest
Do less work when testing your Python code, but be just as expressive, just as elegant, …