Skip to main content
EuroPythonCode of ConductLive 📹

Dance with shadows: stubs, patch and mock

Liffey Hall 2
Start (Dublin time):
Start (your time):
30 minutes


To ensure quality, automated testing is a must. But sometimes is impossible or very expensive to use real environments. In this case, you can isolate some parts of a system and use fake simulated objects.



A comprehensive but simple introduction to the use of fake objects. Explain how to inject this object and use in test using patch and the awesome and powerful mock objects . Last, I present some very interesting specialized libraries for mocking on web development.


0:00 I present the key factors to use fake objects, and present some dangers.

3:00 Discuss some wanted characteristics in this kind of components.

6:00 Patching: how to do that and some common mistakes. After that I present patch scopes and some disadvantage in the use of this technique.

10:00 Inverse dependency as an possible alternative to patch

13:00 Mocks properties: return value, side effect and specs. Using mocks as spy functions or wrappers. Asserting on callings.

21:00 Using special libraries for mocking. Presenting pyvcr and moto.

The speaker

María Andrea Vignau

I gave many talks in spanish and two in english. I come from Argentina and gave five talks on PyCon Argentina, gave a talk in Europython, a charla at PyCon Charlas 2019, and this year in PyCon España and other for Basis Technology on extending forensic software using python ( I was also organizer in 9 events in my city, Resistencia Chaco, collaborator in many others, including mentoring at PyCon Charlas 2022.

← Back to schedule