Take the 2-minute tour ×

What is your single favorite mocking library for Python?

share|improve this question

closed as not constructive by Justin Cave, Bill the Lizard Feb 22 '12 at 1:57


minimock which uses doctest –  Prof. Falken Jan 25 '13 at 9:40
"Mockito is a mocking framework that tastes really good. It lets you write beautiful tests with clean & simple API. Mockito doesn't give you hangover because the tests are very readable and they produce clean verification errors." code.google.com/p/mockito –  mit Mar 21 at 12:55

7 Answers 7

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.



share|improve this answer
mock is now part of the Python standard library, available as unittest.mock in Python 3.3 onwards. –  naxa May 9 '13 at 10:11

Mox, from Google

share|improve this answer
I find it poorly documented, in a very non-intuitive way. –  Régis B. Jan 26 '12 at 19:22

Mocker from Gustavo Niemeyer.

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

share|improve this answer
Mocker is extensively covered in Daniel Arbuckle's "Python Testing: Beginner's Guide" (Packt). –  Graham King Jan 24 '11 at 5:50

Dingus, by Gary Bernhardt.

share|improve this answer

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

share|improve this answer
The url redirect to a Chinesse site. bitbucket.org/DavidVilla/python-doublex –  ssoto Jan 8 at 13:36

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


share|improve this answer

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.

share|improve this answer
That's what the pMock's author says about pMokc: "Just to note that pMock is no longer in development (really must update the web page), actually it was more an experiment I finished playing with about four years ago and assumed the "alpha" designation would scare people away." [brunningonline.net/simon/blog/archives/002262.html] –  ssoler Mar 31 '11 at 8:51
