[TIP] ANN: mock 0.7.0 beta 1

Michael Foord michael at voidspace.org.uk
Tue Jun 22 07:35:13 PDT 2010


Hello all,

I've done a new release of the mock module, the first in a while. Konrad 
Delong has joined me as a maintainer of mock and has been a great help 
in getting this release out. As there are several major new features 
this is a beta release, with 0.7.0 final coming out in a few weeks 
assuming there are no major problems discovered. Please download it and 
try it out:

* http://pypi.python.org/pypi/mock/0.7.0b1

mock is a Python module that provides a core Mock class. It is intended 
to reduce the need for creating a host of trivial stubs throughout your 
test suite. After performing an action, you can make assertions about 
which methods / attributes were used and arguments they were called 
with. You can also specify return values and set needed attributes in 
the normal way.

mock is tested on Python versions 2.4-2.7 and Python 3.

Full documentation is included in the distribution.

Changes in 0.7.0 (including the much awaited magic method support) are:

* Addition of ``mocksignature``
* Ability to mock magic methods
* Ability to use patch and patch.object as class decorators
* Renamed ``patch_object`` to ``patch.object`` (``patch_object`` is 
deprecated)
* Addition of ``MagicMock`` class with all magic methods pre-created for you
* Python 3 compatibility (tested with 3.2 but should work with 3.0 & 3.1 as
   well)
* Addition of ``patch.dict(...)`` for changing dictionaries during a test
* Addition of ``mocksignature`` argument to ``patch`` and ``patch_object``
* ``help(mock)`` works now (on the module). Can no longer use ``__bases__``
   as a valid sentinel name (thanks to Stephen Emslie for reporting and
   diagnosing this)
* Addition of soft comparisons: call_args, call_args_list and method_calls
   return now tuple-like objects which compare equal even when empty args
   or kwargs are skipped
* Added some docstrings.
* BUGFIX: ``side_effect`` now works with ``BaseException`` exceptions like
   ``KeyboardInterrupt``
* BUGFIX: patching the same object twice now restores the patches correctly
* The tests now require `unittest2 <http://pypi.python.org/pypi/unittest2>`_
   to run
* `Konrad Delong <http://konryd.blogspot.com/>`_ added as co-maintainer

The main tasks before a 0.7.0 final release are finishing the 
documentation and docstrings, plus allowing `patch.dict(...)` to act as 
a context manager (currently decorator only).

All the best,

Michael Foord

-- 
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog

READ CAREFULLY. By accepting and reading this email you agree, on behalf of your employer, to release me from all obligations and waivers arising from any and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and acceptable use policies ("BOGUS AGREEMENTS") that I have entered into with your employer, its partners, licensors, agents and assigns, in perpetuity, without prejudice to my ongoing rights and privileges. You further represent that you have the authority to release me from any BOGUS AGREEMENTS on behalf of your employer.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20100622/c5bc7e88/attachment.htm>


More information about the testing-in-python mailing list