[Python-ideas] doctest

Raymond Hettinger raymond.hettinger at gmail.com
Wed Feb 29 20:30:36 CET 2012

On Feb 17, 2012, at 1:57 PM, Mark Janssen wrote:

> I find myself wanting to use doctest for some test-driven development,
> and find myself slightly frustrated 

ISTM that you're doing it wrong ;-)
Doctests are all about testing documentation, not about unittesting.

And because they are very literal (in fact, intentionally stupid
with respect to whitespace), doctests are inappropriate for
test driven development.  It is *much* easier to test the function
by hand and then cut-and-paste the test/result pair into the docstring.

Extending the doctest module to support your style of using it
would likely be counter-productive as that would encourage
more people to use the wrong tool for the job -- the doctest
style is almost completely at odds with the principles of
unittesting (i.e. isolated/independent tests, etc).

My clients tend to use doctests quite a bit (that is what I teach),
yet the need for doctest extensions almost never arises when
it is being used as designed.

I suggest that you try out some other third-party testing packages
that are designed to accommodate other testing styles.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20120229/f7d18db3/attachment.html>

More information about the Python-ideas mailing list