ANN: mock 0.7.0 beta 4 release

Fuzzyman fuzzyman at gmail.com
Tue Nov 16 13:52:54 CET 2010


I've released mock 0.7.0 beta 4. This is intended to be the last
release of 0.7.0 before the final.

http://pypi.python.org/pypi/mock/ (download)
http://www.voidspace.org.uk/python/mock/ (documentation)
https://code.google.com/p/mock/ (repo and issue tracker)

mock is a Python library for simple mocking and patching (replacing
objects with mocks during test runs). The "headline features" in 0.7.0
are Python 3 support and the ability to mock magic methods. You can
now mock objects that behave like containers or are used as context
managers. mock is designed for use with unittest, based on the "action
-> assertion" pattern rather than "record -> replay". People are
happily using mock with Python test frameworks like nose and py.test.

0.7.0 is a major new release with a bunch of other new features and
bugfixes as well.

The latest beta is now up on PyPI. 0.7.0 beta 4 is intended to be the
last release before 0.7.0 final (read my lips - no new features), so
please try it out and report any issues.

The work remaining before the final release is updating the
documentation, especially the examples, to include the new features.

Changes since beta 3 are:

    * patchers (patch, patch.object and patch.dict) have start and
stop methods
    * Addition of assert_called_once_with method
    * repr of a mock with a spec includes the class name of the spec
    * assert_called_with works with python -OO
    * New spec_set keyword argument to Mock and patch. If this is set,
attempting to set an attribute on a mock not on the spec will raise an
AttributeError
    * Attributes and return value of a MagicMock are MagicMock objects
    * Attempting to set an unsupported magic method now raises an
AttributeError
    * patch.dict works as a class decorator
    * Switched from subversion to mercurial for source code control
    * BUGFIX: mocks are now copyable (thanks to Ned Batchelder for
reporting and diagnosing this)
    * BUGFIX: spec=True works with old style classes
    * BUGFIX: mocksignature=True can now patch instance methods via
patch.object

For more details, including full changelog since 0.6.0 and examples of
using the new start / stop methods on patchers, see the announcement
on my blog:

http://www.voidspace.org.uk/python/weblog/arch_d7_2010_11_13.shtml#e1193

All the best,

Michael Foord


More information about the Python-announce-list mailing list