Karellen

Karellen is the future of DevOps.

More coming soon.


How to spy on Mock-wrapped method calls in Python

You have a class whose API you want to verify: You write the following test fully expecting it to pass. Alas, the method_Y assertion fails. This is because the Python Unittest Mock, while wrapping mock.method_X(), Mock uses obj in the __self__ of the method_Y binding. As a result the self value passed to method_X is … Continue reading “How to spy on Mock-wrapped method calls in Python”

Posted in Hacking, Karellen, Projects, Tutorials | Tagged , , , | Leave a comment