In <[EMAIL PROTECTED]>, john_sips_tea
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? (I notice there's no mention in PEP 3000 of deprecating
> the doctest module).

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.

Testing real examples in doctstrings, or external documentation like
tutorials, is important because it's very frustrating for people reading
the docs if the examples don't work as advertised.

Ciao,
        Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to