[TIP] doctest and floats

Noah Gift noah.gift at gmail.com
Tue Mar 11 07:12:44 PDT 2008

All of this brings up an interesting question about doctests, which I  
happen to prefer to unittests btw. If you write a doctest, and "fake  
it out" to accurately test your code, which is worse, an inaccurate  
doctest, which can be interpreted as documentation, or an incompletely  
tested module?  This has been a dilemma for me in some situations,  
although I probably don't know all of the doctest tricks yet.

On Mar 11, 2008, at 10:00 AM, Benji York wrote:

> Tim Head wrote:
>> It feels wrong to write
>>>>> foo(0.1)
>> 0.10000000000000001
> doctest lets you install your own output checker that can compare the
> expected and actual output more intelligently.  For an example, see
> http://svn.zope.org/zope.testing/trunk/src/zope/testing/renormalizing.py?view=markup
> -- 
> Benji York
> http://benjiyork.com
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python

Noah Gift / http://noahgift.com

More information about the testing-in-python mailing list