473,327 Members | 1,976 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

ANN: Mock 0.4.0 released

Mock 0.4.0 has just been released, the first release in about ten
months (but worth the wait).

Mock is a simple library for testing: specifically for mocking,
stubbing and patching.

* Mock Homepage & Documentation http://www.voidspace.org.uk/python/mock.html
* mock.py (module only) <http://www.voidspace.org.uk/downloads/mock.py
* mock-0.4.0.zip (module, tests and documentation) <http://
www.voidspace.org.uk/downloads/mock-0.4.0.zip
* mock.txt (documentation) <http://www.voidspace.org.uk/python/docs/
mock.txt
* Google Code Home & Subversion Repository <http://code.google.com/p/
mock/

This new release brings in some cool new features, but some are
backwards incompatible so read the release notes if you are updating.
Thanks to all those who emailed me with
suggestions and feature requests - *most* of them got in one way or
another...

What is Mock?
===========

Mock makes simple mocking trivially easy. It also provides decorators
to help patch module and class level attributes within the scope of a
test. In this release the ``patch`` decorator got even easier to use.
You can now call it with one argument - a string which is the fully
qualified name of the object you wish to patch, in the form
'package_name.module_name.ClassName'. ``patch`` patches the class in
the specified module with a Mock object, which is passed in to the
decorated function. (As well as ``patch`` creating mocks for you, you
can also explicitly pass in an alternative object to patch with.)
What's New?
==========

The are now eggs (for Python 2.4-2.6) up on the `Mock Cheeseshop Page
<http://pypi.python.org/pypi/mock/>`_. This means that if you have
setuptools you should be able to install mock with:

``easy_install mock``

The full changelog is:
* Default return value is now a new mock rather than None
* 'return_value' added as a keyword argument to the constructor
* New method 'assert_called_with'
* Added 'side_effect' attribute / keyword argument called when mock is
called
* patch decorator split into two decorators:

- ``patch_object`` which takes an object and an attribute name to
patch
(plus optionally a value to patch with which defaults to a mock
object)
- ``patch`` which takes a string specifying a target to patch; in
the form
'package.module.Class.attribute'. (plus optionally a value to
patch with which defaults to a mock object)

* Can now patch objects with ``None``
* Change to patch for nose compatibility with error reporting in
wrapped functions
* Reset no longer clears children / return value etc - it just resets
call count and call args. It also calls reset on all children (and
the return value if it is a mock).

Thanks to Konrad Delong, Kevin Dangoor and others for patches and
suggestions.

See the following for examples of using Mock and patch:

* http://www.voidspace.org.uk/python/w...11.shtml#e1019
Oct 13 '08 #1
0 1042

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Alexander DEJANOVSKI | last post by:
JyRetic 1.0RC3 was just released. (http://retic.sourceforge.net) Changes are (I might have forgotten some bug fixes): - Bug fix : Scheduled events didn't work if no parameter file was required...
9
by: Peter Hansen | last post by:
The term "mock filesystem" refers to code allowing unit or acceptance tests to create, read and write, and manipulate in other ways "virtual" files, without any actual disk access. Everything is...
0
by: Peter Hansen | last post by:
Along the lines of my post just now about a mock filesystem, I'm also interested in any work in the area of mock timing. Testing time-based* systems can be a real bitch. The most annoying part...
1
by: ischenko | last post by:
There is a (relatively) widely used technique in unit testing, called mock objects. There is even a pMock library which provides a Mock class for a Python environment. Given the "duck typing"...
6
by: Chad Z. Hower aka Kudzu | last post by:
I debated over whether or not to post this on the .ann group or not. Its not an announcement as I am really looking for feedback only on the asp.net relative portions. This does of course require...
4
by: David Thielen | last post by:
Hi; Are there mock objects anywhere that I can use to write nunit tests for my code behind methods? -- thanks - dave david_at_windward_dot_net http://www.windwardreports.com
0
by: YellowFin Announcements | last post by:
Security solutions provider EXTOL MSC Berhad has developed a neural network predictive analysis engine and is now working with Australian business intelligence company Yellowfin to develop a front...
5
by: =?ISO-8859-1?Q?Gerhard_H=E4ring?= | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 pysqlite 2.5.0 released ======================= I'm pleased to announce the availability of pysqlite 2.5.0. This is a release with major new...
0
by: Wingware | last post by:
Hi, Wingware has released version 3.1.4 of Wing IDE. This bug fix release is available for all three product levels of Wing IDE. *Release Highlights* This release includes the following: ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.