There are many mocking libraries for Python out there. Due to the dynamic nature of Python I find them an overkill. Below is a super simple mocking library that works for me.
Note that for some types (such as C extensions, objects with __slots__ ...) this will not work since they do not have a __dict__.
EDIT: Following HackerNews comments , I've changed the interface to mock(obj, **kw).