[TIP] ANN: Fudge 1.0 - YAMF (yet another mock framework)

Herman Sheremetyev herman at swebpage.com
Fri Feb 25 19:38:44 PST 2011


On Sat, Feb 26, 2011 at 7:19 AM, Kumar McMillan
<kumar.mcmillan at gmail.com> wrote:
> Everyone else is doing it, right?!  Mock testing tools abound!
> http://farmdev.com/thoughts/90/fudge-goes-1-0/
> http://farmdev.com/projects/fudge/
>
> Fudge has come along way since its 0.9.0 release in late 2009.  As the
> flexmock docs point out, one of its major flaws in 0.9 was that you
> had to manage setup/teardown so that expectations got verified.  Since
> 1.0 that is no longer the case.  The docs above explain how it works
> but as a spoiler: I basically stole mock's @patch method.  I always
> liked the way @patch worked but never thought it would add much value
> to Fudge.  Then one day, while working on a mock based suite [1], it
> dawned on me that this would be a perfect way to seamlessly inject
> fudge's verification step.  Unlike flexmock it requires a decorator
> but also unlike flexmock it doesn't couple you to your test runner.

Hate to jump on your thread to talk about another project, but since
you explicitly call it out... :)

Flexmock is actually only as coupled to the runner as the tests
themselves. That is, flexmock won't break your tests because you
switch runners, the integration still works as long as the test is
found and executed. At least this is true for the currently supported
and known to work ones: unittest(2), nose, and py.test. I have a
feeling some of the other runners will just work as well, as I've
found to be the case with py.test -- it just needed custom code for
py.test specific features, and custom testing in the flexmock test
suite itself.

I'm not sure how often people change their runners, but flexmock adds
a minimal burden in that situation, if any. You probably want to
adjust your import line to ensure flexmock fully supports the runner's
unique features, but if you're switching from another runner I'd wager
you wouldn't be having any of those tests in there anyway.

Cheers,

-Herman



More information about the testing-in-python mailing list