Skip to Main Content
Understanding Unittest.Mock
on-demand course

Understanding Unittest.Mock

with Mario Corchero
January 2019
Beginner content levelBeginner
1h 22m
English
Apress
Closed Captioning available in English

Overview

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.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Reinventing the Organization for GenAI and LLMs

Reinventing the Organization for GenAI and LLMs

Ethan Mollick

Publisher Resources

ISBN: 9781484244135