For those about to Mock I salute you!
summary
Covers concrete recipes: uses unittest and pytest for assertions and parametrized runs, shows replacing external dependencies with stubs (namedtuple), magic mocks and patching to assert calls, and using mock.side_effect to raise errors or iterate return values. Demonstrates mocking built-ins like open with BytesIO, testing requests by patching request.session, and recording/playback of real HTTP responses with betamax cassettes; also shows API workflow testing with gabbi.
AI-written summary · about
chapters (22)
- 0:00Introduction
- 1:00Why I test
- 2:00Tools
- 2:30Unit Tests
- 4:03Setting up Unit Tests
- 5:45Testing Vocabulary
- 8:20Unit Test
- 8:49Run
- 9:03Results
- 9:48stub
- 10:23JSON
- 10:51MagicMock
- 13:34Exception Handling
- 14:01Value Error
- 15:43Blow up JSON
- 17:50Mock
- 31:57Betamax
- 34:22Test
- 37:31API endpoints
- 38:43Gaby
- 40:19Cheap tricks
- 42:26Parametrization
related talks
39mIntro to Mocking: Why Unit Testing Doesn't Have To Be So Hard
29mUnit testing in the real world with mock
26mMocking: virtual reality for your Python tests
27mI Dance with Your Shadow: Patch, Stub, Mock
32mMock It Till You Make It: How to Verify Your External Mocks Without Ever...
20mMock, patch - when and how to use
02h 13mPython Unit Testing with Pytest and Mock
23mMocking of mocks. A deep dive into the mock module
