doctest, unittest, or if __name__='__main__'

Terry Hancock hancock at
Wed Mar 22 00:39:42 CET 2006

On Tue, 21 Mar 2006 22:26:57 +0100
Christoph Zwerschke <cito at> wrote:
> john_sips_tea at wrote:
> > If unittest is the standard way to write test code, why
> > do we still have doctest? (I notice there's no mention
> > in PEP 3000 of deprecating the doctest module).
> Because both have their pros and cons and their right to
> exist. Doctest  is really easy to use and you can kill two
> birds with one stone.
> Rather than removing one of the two, I would like to see
> yet another  alternatise such as py.test in the standard
> lib, because unittest is  indeed standard, but clumsy and
> un-pythonic.

Doctest is very easy to use, so it's easy to ensure that
tests get written. OTOH, they're only really good for stuff
that can be easily tested in the interpreter (e.g. that can
be easily verified from their text output).  When you get
into stickier stuff like graphics and web programming, the
formal structure of pyunit can be easier to adapt than
something which is intrinsically based on string processing.

Haven't seen py.test before, but I'm looking now -- thanks
for the link. :-)


Terry Hancock (hancock at
Anansi Spaceworks

More information about the Python-list mailing list