doctest, unittest, or if __name__='__main__'

Fredrik Lundh fredrik at pythonware.com
Fri Mar 24 03:24:42 EST 2006


Marc 'BlackJack' Rintsch wrote:

> I see it this way: `unittest` is for testing code and `doctest` is for
> testing examples in docstrings.  If you put all your tests in the
> docstrings there will be much code that's quite irrelevant for documenting
> the function/method/class.

so put the tests in your test program instead, and use doctest to make
sure that the test program works as advertised.

(or use doctest on separate test scenario documents)

if you prefer the doctest approach, there's no reason to use unittest for
anything.

</F>






More information about the Python-list mailing list