I am pleased to announce the first release of Python Mock (version
0.1.0) on SourceForge:
About Python Mock
The Python Mock library enables the easy creation and use of Mock
objects for Python unit testing, inspired by the various Java mock
Mock objects facilitate unit testing by acting as replacements for
classes that the object being tested must interact with. The Mock
object can accept any method call and return a canned value. The call
is recorded by the Mock object and can be examined later by the test
The Mock objects can have expectations about how they are used, to
assert that they are being used correctly. The Mock objects can also
validate themselves against the class being mocked, checking that the
methods called exist on the real object and have the right parameters.
This ensures that the tests stay in sync with the classes being mocked.
The Mock class can also be used to as a mixin with a regular Python
class to provide recording of method calls and setting expectations on
non-Mocked methods. This enables the Mock class to be used for
diagnostic purposes as well as for testing.
Python Mock was originally launched in 2001 on the Extreme Programming
Yahoo Group by Dave Kirby, but has not been widely available outside of
the group. It has recently been updated and enhanced with the
assistance of Bruce Cropley. It is under active development by both
Dave and Bruce, so expect more releases in the near future.
Python Mock is released under the BSD license and is free for both
commercial and non-commercial use.