[Python-3000] doctests vs. unittests (was Re: pimp; restructuring the standard library)

Stephan Richter srichter at cosmos.phy.tufts.edu
Fri Jun 29 18:39:34 CEST 2007


On Friday 29 June 2007 01:40, Chris McDonough wrote:
> I don't mind doctest at all really (I just use unittest out of  
> inertia and personal preference, I'd probably just as happy with nose  
> or whatever).  I just don't like when folks advertise the same  
> doctest as both a comprehensive set of tests and a component's only  
> source of documentation, because I don't think it's possible for it  
> to be both at the same time with any sort of quality in both  
> directions simultaneously.

I could not disagree more. My personal rule is that any released code should 
be 100% coverage tested. And I never write regular unittests anymore, unless 
for some super-specific cases. Alos, people compliment me about good 
documentation all the time. Have a look at 
http://svn.zope.org/z3c.form/trunk/src/z3c/form/. the documentation is 
example driven, yet still covers all of the API.

Having said that, writing comprehensive doctests that do not read like a CS 
thesis is very hard. It took me the last 5 years developing Zope 3 to learn 
how to do that right. 

BTW, I do agree with what Phillip and Barry wrote. I always consider it a 
challenge to see how many lines of testable documentation I can write before 
writing one line of code -- I max out at about 2k right now.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training


More information about the Python-3000 mailing list