Python mocks with side-effects

https://blog.narf.ssji.net/2025/08/31/python-mocks-with-side-effects/

I wrote a simple Python fixture that allows me to write integration tests to also check whether methods are called along the way. This is handy to test caching and other state-based lazy behaviour, without having to write a separate unit test that duplicates most of the test case flow.

… But you should just use the existing `wraps` argument to `unittest.mock[.object].patch`

#mocking #Pytest #Python #testing