What is your favorite Python mocking library? [closed]

Posted on

Question :

What is your favorite Python mocking library? [closed]

What is your single favorite mocking library for Python?

Answer #1:

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

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.

Answered By: Daryl Spitzer

Answer #2:

Mox, from Google

Answered By: John Millikin

Answer #3:

Mocker from Gustavo Niemeyer.

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

Answered By: ddaa

Answer #4:

Dingus, by Gary Bernhardt.

Answered By: John Eikenberry

Answer #5:

I’m the author for mocktest. I think it’s pretty fully featured and easy to use, but I might be biased:


Answered By: gfxmonk

Answer #6:

pyDoubles the test doubles framework for Python, by iExpertos.com. It supports mocks, stubs, spies and matchers, including Hamcrest matchers

Answered By: Carlos Ble

Answer #7:

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.

Answered By: William Keller

Leave a Reply

Your email address will not be published. Required fields are marked *