27
Jan
4

Python Mocker or PyMox?

Mocker and PyMox are two isolation frameworks, or test doubles frameworks able to create mocks and stubs. Mocker is not being released frequently but contains pretty much all the features one need to test-drive. On the other hand PyMox is being developed but it's got an ugly Java-like syntax with does not look like Python. I don't say that Java syntax is ugly, in fact, I like it. What I say is that Python's got its own conventions (PEP-8) and PyMox does not respect it.
Which one to use? I think I need the two of them. PyMox is terrible for stubbing out functions. Awful API for stubs and more than that, it didn't work for me sometimes. However, it's great for mocks. Mocker is nice for stubs and powerful although the proxy/patch stuff is weird. I use both, Mocker for stubs and PyMox for mocks :-)

Enjoyed reading this post?
Subscribe to the RSS feed and have all new posts delivered straight to you.
4 Comments:
  1. Gustavo Niemeyer 27 Jan, 2010

    Mocker isn’t dead at all. It’s in active use by its author (myself) and many others.

  2. Carlos Ble 27 Jan, 2010

    Sorry Gustavo, I thought the project was dead. I wrote to you last year about some bug or something and never got an answer. There are now news in its site and I haven’t seen any post in your blog regarding Mocker in a long time. Moreover the last public release is 0.10.1. It would be great if you release a new version. I’ve fixed the blog post removing “mocker is dead” because it is not.
    It would be very cool if you add the syntax

    expect(object.method_to_mock(params)).and_return(whatever)

    for mocks, and also de syntax:

    in_case(object.method_to_stub(params)).then_return(whatever)

    for stubs.

    Thanks for a great doubles framework :-)

  3. Néstor Salceda 27 Jan, 2010

    Hey Carlos,

    Perhaps you wanna take a look to fudge: http://farmdev.com/thoughts/70/fudge-another-python-mock-framework/

    I use it, and it looks nice :)

  4. Carlos Ble 28 Jan, 2010

    Thanks Nestor! Didn’t know about that framework. Will check it out :-)

Post your comment



Celadon theme by the Themes Boutique
teeth bleaching
baldness treatment