Mocker 0.9

Gustavo Niemeyer gustavo at niemeyer.net
Sat Nov 17 21:42:30 CET 2007


Greetings!

Mocker 0.9 has just been released.  The list of changes is
provided below.

Where
-----

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.9
--------------

- Added MockerTestCase.makeFile() and .makeDir() helpers.  They offer
  easy creation of temporary files/directories, and ensure that they
  get removed after each test method runs.

- Added MockerTestCase.assertMethodsMatch().  It will verify if all
  public methods found in the class passed as the first argument are
  also present in the class passed as the second argument, and that
  they accept the same arguments.  This is useful to verify if a fake
  or stub class have the same API as the real class being simulated.

- Added MockerTestCase.assert[Not]{Starts,Ends}With().

- If the replay() method is called twice, expectations will be fully
  reset so that several similar tests may be performed in a row by
  just calling replay() again.

- Mocker.on_restore() removed.  Restore isn't performed if replay()
  isn't called, and that may not be obvious, so a hook won't be
  exposed for now.

- When using a non-existent import path for Mocker.proxy(), raise an
  ImportError on the base module, rather than using the actual
  string as the object (#162315).


-- 
Gustavo Niemeyer
http://niemeyer.net



More information about the Python-announce-list mailing list