Mock It Till You Make It: How to Verify Your External Mocks Without Ever...
summary
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
chapters (15)
- 0:00Introduction
- 3:23Software testing and unit tests
- 7:43Mocking essentials
- 10:13Mock best practices
- 13:26Demo and mock verification
- 16:00Debugging mock failures
- 18:12Skipping real API calls
- 19:16Resources and closing
- 21:10Q&A
- 21:46Unit testing adoption
- 23:10Mocking in doctests
- 24:37Mock instance methods
- 26:48Mocks outside unit tests
- 28:40Convincing teams to mock
- 30:10Fixing over-mocked tests
related talks
49mFor those about to Mock I salute you!
26mMocking: virtual reality for your Python tests
39mIntro to Mocking: Why Unit Testing Doesn't Have To Be So Hard
29mUnit testing in the real world with mock
24mTesting Your Python Code
45mStop Using Mocks (for a while)
23mMocking of mocks. A deep dive into the mock module
02h 13mPython Unit Testing with Pytest and Mock
