Mocking library focusing on very explicit definition of the mocks' behaviour
DO NOT USE THIS LIBRARY: there is now a standard mocking library in Python. I will not fix anything in this library and I’m migrating my own projects to unittest.mock.
MockMockMock is a Python (2.7+ and 3.3+) mocking library focusing on very explicit definition of the mocks’ behaviour. It allows as-specific-as-needed unit-tests as well as more generic ones.
Install from PyPI:
$ pip install MockMockMock
>>> from MockMockMock import *
Write some code to test:
>>> def f(source): ... return source.get(42) * 2
>>> mocks = Engine() >>> mock = mocks.create("mocks")
>>> assert f(mock.object) == 24
Verify all expected calls have been done: