Overview
Save Big on Coursera Plus. 7,000+ courses at $160 off. Limited Time Only!
Explore a beginner's guide to mock objects in Python 3 through this 25-minute conference talk from EuroPython 2016. Learn about the unittest.mock package, including the Mock class, sentinels, and patching techniques. Discover how to write easy and reliable tests for challenging code, understand the benefits and potential pitfalls of using mocks, and familiarize yourself with mock-related terminology such as "SUT," "Stub," "Double," and "Dummy." Progress through increasingly complex examples, from simple use cases to more problematic scenarios. Gain insights into different mocking approaches, including "mockist" testing, and learn about the mockextras package for enhanced mock functionality. By the end of this talk, acquire practical skills to effectively implement mock objects in your Python testing workflow.
Syllabus
Intro
Testing the Untestable A beginner's guide to mock objects
Easy Example
Not so easy
If it quacks like a duck...
Mock FTW!!!
It's Mocks all the way down
parlez-vous mocks?
Assertions
Spec
Harder Example
Sentinels
return_value
@patch
return values side effect
side_effect
Making conversation
Stubs
Mockextras
Beware the Dark Side
Two Schools
Over-mocking
ISO-K1773N5
Overmocked
Summary
Questions
Taught by
EuroPython Conference