~/talk

Mocking of mocks. A deep dive into the mock module

TalkinSpanishat PyConES 2018 · 2018-10-05..10-07· [testing, python]
slides:none on file

An in-depth look at Python’s mock module, explaining how to create and use mock objects for testing. Covers techniques for nesting and composing mocks, common pitfalls when mocking dependencies, and practical examples using the mock API (patch, MagicMock, side_effect, etc.).

AI-written summary · about

  1. 0:00Mocks in Python
  2. 1:26Why use mocks?
  3. 3:12Basic Mocks
  4. 5:40MagicMock vs Mock
  5. 7:03Side effects in mocks
  6. 8:06Mocking functions
  7. 8:27Mock patch for dependencies
  8. 10:34Common mock problems
  9. 11:37Spec and autospec in Python 3.7
  10. 13:23Mocking real objects
  11. 14:25Sentinels in mocks
  12. 15:27How patch works
  13. 16:54Correct patching scope
  14. 17:36Named mocks
  15. 18:20Verify mock calls
  16. 19:23Practical mock example
  17. 21:31Common errors and fixes
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.