Python: spy on function calls with unittest.mock’s wraps
Testing terminology distinguishes between different kinds of test doubles, including:
- mocks, which replace the real behaviour of a function.
- spies, which wrap a function, recording calls for later assertions.
Despite its name, unittest.mock is not just for mocks: it can also create spies, through the wraps argument of its …