What is your favorite Python mocking library?

PythonMocking

Python Problem Overview


What is your single favorite mocking library for Python?

Python Solutions


Solution 1 - Python

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.

Solution 2 - Python

Mox, from Google

Solution 3 - Python

Mocker from Gustavo Niemeyer.

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

Solution 4 - Python

Dingus, by Gary Bernhardt.

Solution 5 - Python

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

http://gfxmonk.net/dist/doc/mocktest/doc/

Solution 6 - Python

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

Solution 7 - Python

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDaryl SpitzerView Question on Stackoverflow
Solution 1 - PythonDaryl SpitzerView Answer on Stackoverflow
Solution 2 - PythonJohn MillikinView Answer on Stackoverflow
Solution 3 - PythonddaaView Answer on Stackoverflow
Solution 4 - PythonJohn EikenberryView Answer on Stackoverflow
Solution 5 - PythongfxmonkView Answer on Stackoverflow
Solution 6 - PythonCarlos BleView Answer on Stackoverflow
Solution 7 - PythonWilliam KellerView Answer on Stackoverflow