[TIP] Mocking frameworks

Ben Finney ben+python at benfinney.id.au
Sun Apr 4 02:11:09 PDT 2010

Kev <kevin.p.dwyer at gmail.com> writes:

> I've been googling python mocking frameworks recently to find one that
> provides similar functionality, in terms of expectations, to Jmock2.

Can you describe what features in particular you are looking for, for
those not familiar with that program?

> Does anyone know which python mocking frameworks provide such
> functionality, and where the staste of the art is at the moment?

I find the simplicity and declarative power of ‘minimock’
<URL:http://pypi.python.org/pypi/MiniMock> to make for very readable
tests. Mock objects chatter about what is happening to them on an output
stream, and the test just needs to match that against a string stating
what the expected chatter is. With Python's ‘doctest’ providing the
string matching (including marking “don't care about this part”
sections), it's a nice solution.

 \       “Even if the voices in my head are not real, they have pretty |
  `\                                           good ideas.” —anonymous |
_o__)                                                                  |
Ben Finney

More information about the testing-in-python mailing list