views:

1532

answers:

5

What is your single favorite mocking library for Python?

+6  A: 

I've only used one, but I've had good results with Michael Foord's Mock: http://www.voidspace.org.uk/python/mock.html.

Michael's introduction says it better than I could:

There are already several Python mocking libraries available, so why another one?

Most mocking libraries follow the 'record -> replay' pattern of mocking. I prefer the 'action -> assertion' pattern, which is more readable and intuitive particularly when working with the Python unittest module.

...

It also provides utility functions / objects to assist with testing, particularly monkey patching.

Daryl Spitzer
+1  A: 

I've used pMock in the past, and didn't mind it, it had pretty decent docs too. However, Foord's Mock as mentioned above is also nice.

William Keller
+4  A: 

Mox, from Google

John Millikin
A: 

Mocker from Gustavo Niemeyer.

It's not perfect, but it is very powerful and flexible.

ddaa
+2  A: 

Dingus, by Gary Bernhardt.

John Eikenberry