[TIP] Which mock object framework should I use?

Grig Gheorghiu grig at gheorghiu.net
Sat Nov 17 13:00:50 PST 2007


--- Martin Aspeli <optilude at gmx.net> wrote:

> Grig Gheorghiu wrote:
> > You can add Mocker <http://labix.org/mocker> to the list. Looks
> very
> > well documented and thought out.
> 
> Ah yes, an omission from my side, I had actually looked at it. I
> agree 
> it looks good, but I'd appreciate any pointers to practical
> experience.
> 

I personally have used python-mock
<http://python-mock.sourceforge.net/> and I was fairly happy with it. I
think what the Python testing community needs are more real-life
examples of how they used mock testing techniques. My opinion is that
the techniques are more important than the tools.

I can point you to some examples of code written by Michal Kwiatkowski
for the Cheesecake project:

Definition of mock objects:

http://pycheesecake.org/browser/trunk/tests/unit/_mockup_cheesecake.py
http://pycheesecake.org/browser/trunk/tests/unit/_helper_cheesecake.py

Use of mock objects (to avoid going over the network for retrieving
packages):

http://pycheesecake.org/browser/trunk/tests/unit/test_index_url_download.py
http://pycheesecake.org/browser/trunk/tests/unit/test_index_installability.py


Grig



More information about the testing-in-python mailing list