[Python-ideas] Fwd: doctest

Terry Reedy tjreedy at udel.edu
Tue Feb 28 21:59:53 CET 2012


On 2/28/2012 2:59 AM, Steven D'Aprano wrote:

> Corner cases, in my experience, refer to the implementation: does the
> function work correctly when the input is in the corner? Since this is
> testing the implementation, it shouldn't be in the documentation.

It depends on the function. fact(0) = 1 could go in a doc string. So, I 
think, could combo(0,0) = 1. But sometimes implementations introduce a 
special case that is an artifact of the implementation and definitely 
not belong in a doc string. An real example is approximating the normal 
integral (cumlative normal distribution) with different approximations 
for [0,a] and (a,infinity). Unit tests should test f(a) and 
f(a+epsilonl) and the difference (should be >= 0) to make sure the two 
approximations 'join' properly so as to be transparent to the user. If 
the join point changes, so does the special unit test.

-- 
Terry Jan Reedy




More information about the Python-ideas mailing list