doctest, unittest, or if __name__='__main__'

Fredrik Lundh fredrik at pythonware.com
Tue Mar 21 22:09:14 CET 2006


john_sips_tea at yahoo.com wrote

> For writing testcode, it looks like there's three ways that it's
> typically done:
>
> (1). using the doctest module,
>
> (2). using the unittest module (i.e. "pyunit"), or else
>
> (3). just putting an "if __name__ = '__main__':" at the bottom of your
> module containing code to manually run your class through its paces.
>
> So, which way is preferred? Seems to me that unittest is the way to go,
> at least because it has you separate your test code from the code being
> tested.
>
> If unittest is the standard way to write test code, why do we still
> have doctest?

because it's a vastly superior way to write tests ?

> (I notice there's no mention in PEP 3000 of deprecating
> the doctest module).

why is it that comp.lang.python is suddenly full of folks who
want to deprecate anything they don't understand ?  don't
you have better things to do with your time ?

</F>






More information about the Python-list mailing list