[TIP] [ANN] CaptureMock 1.0 released

Geoff Bache geoff.bache at gmail.com
Mon Apr 7 12:20:54 PDT 2014

Hi all,

I announced this originally a few years ago on this list when it had just
been launched as a separate project. A lot of effort has since gone into it
and it's been used in a few more contexts since then so I've decided to
announce that the current release is 1.0 and that it is now a stable

This is not Yet Another Python Mocking Tool. Its primary aim is to support
functional/acceptance testing rather than unit testing, and to for example
mock out interactions with entire subsystems and third-party modules, as
well as individual method calls.

A major aim is to make it easier to keep mocks in synch with the real
system behaviour, indeed to be able to generate them from it. This both
saves effort and provides insurance against the common problem where mock
code and real code gradually diverge.

The approach is therefore to generate mocks by recording interaction with
the real system, and to then be able to use them in replay mode. So there
are two "modes" to run every test. *Note* that this is genuine
record-replay like GUI-test tools have, not the kind available in e.g.
Mocker or Easymock.

Using it in your tests is very simple. For example:

from capturemock import capturemock

def test_something_sending_email():
     # etc

def test_some_real_time_code():
     # etc

def test_my_graph_stuff():
     # etc

You can then set the environment variable CAPTUREMOCK_MODE to determine
whether it will use pre-existing mocks to replay from, or regenerate them
from real behaviour.

For more details please see the website at

Marc Abramowitz has also put up some more realistic examples at

Geoff Bache
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20140407/20cfdbe5/attachment.htm>

More information about the testing-in-python mailing list