Mocker 0.9

A few more improvements were made to Mocker.

This entry was posted in Project, Python. Bookmark the permalink.

6 Responses to Mocker 0.9

  1. alex dante says:

    Hey there. Very impressed with mocker, it’s great to work with, although I initially thought there was an issue with it due to it’s behaviour under iPython:

    In [1]: from mocker import Mocker
    In [2]: mocker = Mocker()
    In [3]: mock = mocker.mock()
    In [4]: mock.test1()
    Out[4]:
    In [5]: mocker.result(‘test1’)
    In [6]: mocker.replay()
    In [7]: mock.test1()
    Out[7]:

    This behaves correctly under the bare interpreter, although it also outputs the “<mocker.Mock object …” line (is this correct? it’s not shown in the docs…). Any ideas on how I can get mocker running properly under iPython?

    Thanks for an incredibly handy module!

  2. alex dante says:

    Sorry, the output lines got eaten, they’re both displaying repr output that reads: “mocker.Mock object at 0xb78e058c”

    cheers

  3. The problem here is that IPython performs some basic inspection in the mock object, which ends up recording an action. I’ll release a new version of Mocker which fixes this problem.

    Thanks for reporting it.

  4. alex dante says:

    Awesome, thank you!

  5. Mike Pirnat says:

    I’ve been using PyMock a lot, and I’m very happy to see that Mocker addresses a lot of my complaints about PyMock, not the least of which is documentation—thanks for the clear examples in the tutorial!

    There appears to be an error in the first example in the tutorial, though. Instead of “mock.restore()” and “mock.verify()”, I believe it should be “mocker.restore()” and “mocker.verify()” since the mock objects themselves seem to be upset about receiving unexpected expressions if you try to call these methods on them instead of on the Mocker instance.

    Cheers!

  6. Oops.. it was incorrect indeed. I’ve fixed that, and have also renamed all “mock” instances in the documentation to “obj”, reducing a bit the volume of “mock” prefixes and thus the confusion.

    Thanks for reporting this.

Leave a Reply

Your email address will not be published. Required fields are marked *