[TIP] Python mock library comparison

Michael Foord fuzzyman at voidspace.org.uk
Mon Mar 7 12:48:20 PST 2011


On 06/03/2011 07:41, Kumar McMillan wrote:
> On Sun, Feb 27, 2011 at 7:21 PM, Gary Bernhardt
> <gary.bernhardt at gmail.com>  wrote:
>>   - Fudge and MiniMock examples (Kumar? Ian?)
>>
>> Pull requests are welcome!
>> https://github.com/garybernhardt/python-mock-comparison
> Thanks Gary.  It's pretty cool to see everything side by side.  Here
> is the Fudge section:
> https://github.com/kumar303/python-mock-comparison/compare/master
> (pull request sent)
>
> fwiw, I'm not a huge fan of abstract code examples using some_object,
> some_method, some_value, etc.  I much prefer examples that represent
> realistic situations, even if they are slightly contrived -- it's so
> much easier on my brain!  This was a major requirement for me when I
> wrote fudge's own documentation --
> http://farmdev.com/projects/fudge/using-fudge.html -- and I encourage
> all developers to think up realistic situations when writing code
> samples.

And exactly *which* realistic situation compells you to print "Bird is 
the word" when "bert" logs in via oauth? ;-)

http://farmdev.com/projects/fudge/using-fudge.html#replacing-a-method

I agree that "realistic" examples are better, but some generalisation to 
demonstrate principles is both possible and useful (as your own examples 
exemplify).

FWIW the *specific* examples in the mock comparison originally came from 
a set of comparisons from the mox documentation. Getting valid examples 
working from several different mock libraries is challenging enough that 
starting with this is a good idea. If we are able to extend them for 
better examples then great.

Michael

> That said, I like mocking the open function as a context manager,
> that's something one might do in real life so it will make sense to a
> developer who is considering a mock library.
>
> -Kumar
>
>> --
>> Gary
>> http://blog.extracheese.org
>>
>> _______________________________________________
>> testing-in-python mailing list
>> testing-in-python at lists.idyll.org
>> http://lists.idyll.org/listinfo/testing-in-python
>>
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python


-- 
http://www.voidspace.org.uk/

May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing http://www.sqlite.org/different.html




More information about the testing-in-python mailing list