Fudge Documentation

Fudge is a Python module for using fake objects (mocks and stubs) to test real ones.

In readable Python code, you declare what methods are available on your fake and how they should be called. Then you inject that into your application and start testing. This declarative approach means you don’t have to record and playback actions and you don’t have to inspect your fakes after running code. If the fake object was used incorrectly then you’ll see an informative exception message with a traceback that points to the culprit.

Fudge was inspired by Mocha which is a simpler version of jMock. But unlike Mocha, Fudge does not automatically hijack real objects; you explicitly patch them in your test. And unlike jMock, Fudge is only as strict about expectations as you want it to be. If the type of arguments sent to the fake method aren’t important then you don’t have to declare an expectation for them.

Download / Install

Just type:

$ pip install fudge

You can get the pip command here. Fudge requires Python 2.5 or higher.

Installing for Python 3

As of version 0.9.5, Fudge supports Python 3. Just install distribute and type:

$ python3.x setup.py install

This step will convert the Fudge source code using the 2to3 tool.


The Fudge source can be downloaded as a tar.gz file from http://pypi.python.org/pypi/fudge

Using Mercurial you can clone the source from http://bitbucket.org/kumar303/fudge/

Fudge is free and open for usage under the MIT license.


Please submit bugs and patches, preferably with tests. All contributors will be acknowledged. Thanks!


Fudge was created by Kumar McMillan and contains contributions by Cristian Esquivias, Michael Williamson, and Luis Fagundes.


Table Of Contents

Next topic

Using Fudge

This Page