~/talk

Mock It Till You Make It: How to Verify Your External Mocks Without Ever...

Talkat PyCon US 2024 · 2024-05-15..05-23· [testing]
links:none on file
slides:none on file

Demonstrates verifying external mocks entirely inside unittest by using Python Mock/MagicMock with autospec catches wrong methods via patch to bind to real request attributes, plus using skip tests to occasionally hit real endpoints; builds a demo app "build a pug" that calls OpenAI and Dog API, shows autospec turning silent failures into AttributeError, and runs 10 tests instead of 8 when real API tests execute, proving the approach works end to end.

AI-written summary · about

  1. 0:00Introduction
  2. 3:23Software testing and unit tests
  3. 7:43Mocking essentials
  4. 10:13Mock best practices
  5. 13:26Demo and mock verification
  6. 16:00Debugging mock failures
  7. 18:12Skipping real API calls
  8. 19:16Resources and closing
  9. 21:10Q&A
  10. 21:46Unit testing adoption
  11. 23:10Mocking in doctests
  12. 24:37Mock instance methods
  13. 26:48Mocks outside unit tests
  14. 28:40Convincing teams to mock
  15. 30:10Fixing over-mocked tests
~/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.