Mocker 0.10
Gustavo Niemeyer
gustavo at niemeyer.net
Mon Dec 10 18:55:15 CET 2007
Greetings!
Mocker 0.10 has been released. The list of changes is provided below.
Where
-----
Links to files and documentation are available at:
http://labix.org/mocker
About
-----
- Graceful platform for test doubles in Python (mocks, stubs,
fakes, and dummies).
- Inspiration from real needs, and also from pmock, jmock,
pymock, easymock, etc.
- Expectation of expressions defined by actually using mock objects.
- Expressions may be replayed in any order by default,
- Trivial specification of ordering between expressions when wanted.
- Nice parameter matching for defining expectations on method calls.
- Good error messages when expectations are broken.
- Mocking of many kinds of expressions (getting/setting/deleting
attributes, calling, iteration, containment, etc)
- Graceful handling of nested expressions (e.g.
"person.details.get_phone().get_prefix()")
- Mock "proxies", which allow passing through to the real object on
specified expressions (e.g. useful with "os.path.isfile()").
- Mocking via temporary "patching" of existent classes and instances.
- Trivial mocking of any external module (e.g. "time.time()") via
"proxy replacement".
- Mock objects may have method calls checked for conformance with
real class/instance to prevent API divergence.
- Type simulation for using mocks while still performing certain
type-checking operations.
- Nice (optional) integration with "unittest.TestCase", including
additional assertions (e.g. "assertIs", "assertIn", etc).
- More ...
Changes in 0.10
---------------
- Greatly improved error messages and logic for expression ordering!
- Implemented MockerTestCase.addCleanup(). It allows one to
register cleanup functions to be called after the test is
complete.
- MockerTestCase now verifies if the mocker is put in replay
mode in cases where events were recorded.
- New MATCH() argument matcher, which allows using a function
to match an argument generically. E.g. MATCH(lambda x: x > 10)
- New 'path' option to MockerTestCase.makeFile() and makeDir(),
which allows setting the full target path with a single option.
- Now when a spec is provided (or with proxy/replace/patch) the
existence of the real method is checked even if the mocked
method doesn't execute. This is useful to detect API expectation
errors even if count(0) is used (a negative assertion).
- Implemented in MockerTestCase support for Deferred results as
understood by Twisted Trial's TestCase, so that coexistence by
multiple inheritance is possible and trivial.
- MockerTestCase.makeFile() with content=None (the default) now
consistently returns an unexistent temporary filename which
is properly cleaned up if created.
- Fixed problem when requesting order on similar expressions. The
second expression might not be accepted.
- When the expression executed isn't exactly the same as the
recorded events (e.g. when parameter matchers are used), show in
the error message the real expression run, to aid in debugging.
--
Gustavo Niemeyer
http://niemeyer.net
More information about the Python-announce-list
mailing list