How to use Python's unittest.mock.patch

Опубликовано: 24 Октябрь 2024
на канале: redshiftzero
101,041
1.8k

How to use (and where to apply) Python's unittest.mock.patch in your test suites. In this video I show where to patch, and three ways of applying mock.patch: as a decorator, as a context manager, and inline using mock.patch.start() and mock.patch.stop().

Further reading:

Python docs on unittest.mock.patch: https://docs.python.org/3/library/uni...
Where to patch: https://docs.python.org/3/library/uni...