Mock, patch - when and how to use
summary
Covers Python unit-testing best practices, focusing on when and how to use mocking and patching via Python libraries (likely unittest.mock and related tools) to simplify test development. Includes concrete examples drawn from projects developed over the past few years.
AI-written summary · about
chapters (7)
- 0:00Start
- 2:06Basic test
- 5:29Mock - assert usage
- 11:35Mock request.post
- 13:44Patch & imports
- 16:21Patch - nesting patches
- 17:59Patch - environment variables
related talks
31mHot-swapping Symbols During Tests: Demystifying unittest.mock[.patch]
39mIntro to Mocking: Why Unit Testing Doesn't Have To Be So Hard
49mFor those about to Mock I salute you!
23mMocking of mocks. A deep dive into the mock module
37mDemystifying the Patch Function
27mI Dance with Your Shadow: Patch, Stub, Mock
29mUnit testing in the real world with mock
26mMocking: virtual reality for your Python tests
