[TIP] Doctest or unitest?

Michael Foord fuzzyman at voidspace.org.uk
Wed Mar 7 06:21:46 PST 2007


Benji York wrote:
> Michael Foord wrote:
>> Jim - can you (or someone else) point me to an example source file 
>> which uses doctest for unit testing.
>
> Here's a good, (reasonably) short example:
> http://svn.zope.org/zc.queue/trunk/src/zc/queue/queue.txt?rev=67933&view=markup 
>
The document looks quite nice.

If you had lots of nasty edge case testing which didn't fit well into 
documentation then I guess you could put it into a separate file.

Isn't typing '...' all the time annoying ? (or do you code first, test 
later... ? ;-)

Don't you also lose the help of the IDE with indentation and 
autocomplete because you are no longer writing the tests in Python files ?

We are writing an application (rather than a library), and so don't 
*want* to document all of our internal classes / modules - so 
documentation driven design has little to offer us for these tasks. (and 
so the idea of using doctests becomes even weirder.)

For our acceptance (functional) tests it might be quite a nice way of 
doing them - we'd have to make our automation API look even more like a 
DSL though for it to be readable.


All the best,

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml



More information about the testing-in-python mailing list