[TIP] Which mock object framework should I use?

tarjei tarjei at nu.no
Sun Nov 18 07:59:18 PST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Gustavo Niemeyer wrote:
> Hello Martin,
>
>>> You can add Mocker <http://labix.org/mocker> to the list. Looks
>>> very well documented and thought out.
>> Ah yes, an omission from my side, I had actually looked at it. I
>> agree it looks good, but I'd appreciate any pointers to practical
>> experience.
>
> You won't find many pointers for practical experience with Mocker
> yet, as I've released it publicly only a week ago or so.  Even
> then, I do believe it has a superset of the features of all the
> others, and a few more, in a well packed way.
>
> Please let me know if you have any questions or suggestions about
> it.

Hi,

I come from a mainly php background to the Python world, and I've
mainly been using the pmock library for mocking.

Since you are working on a new Mock implementation, my wishlist is
that you look at the api that is used by the simpletest package
(simpletest.org) for mocking.

What I like about the simpletest api is that it doesn't require too
much typing.

Instead of : (example from pmock)
obj.expects(mock.once()).some_method(mock.eq('myparam'),mock.eq('otherparam')).will(mock.return_value('tt'))
you can have:
obj.expectOnce('some_method', ('myparam','otherparam'), 'tt')

Which is IMHO both more readable and easier to work with.

Kind regards,
Tarjei



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHQGFWYVRKCnSvzfIRAjYXAJ9RASWL97IAFfXmkdnaycksNeahtwCfao+b
Rk+2KuOQYfL00Fc+N466OXU=
=IdtK
-----END PGP SIGNATURE-----

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.idyll.org/pipermail/testing-in-python/attachments/20071118/c7bb5c7c/attachment.htm 


More information about the testing-in-python mailing list