Python Mocker or PyMox?

Update: We have developed our own test doubles framework. It is open source. Please check it out at www.pyDoubles.org

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.
  • http://niemeyer.net Gustavo Niemeyer

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

  • http://carlosble.com Carlos Ble

    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 🙂

  • http://nestor.babuine.net Néstor Salceda

    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 🙂

  • http://carlosble.com Carlos Ble

    Thanks Nestor! Didn’t know about that framework. Will check it out 🙂

  • http://www.blekit.mazurski.mazury.pl/ Moj¿esz

    What an significant document, retain penning mate