[Python-ideas] Fwd: doctest
ned at nedbatchelder.com
Mon Feb 27 21:14:55 CET 2012
On 2/27/2012 2:23 PM, Mark Janssen wrote:
> I just realized I've been replying personally to these replies instead
> of the whole list (damn I hate that!). So resending a bunch of
> messages that went to individuals. [Mark]
> On Fri, Feb 17, 2012 at 3:12 PM, Nick Coghlan<ncoghlan at gmail.com> wrote:
>> On Sat, Feb 18, 2012 at 7:57 AM, Mark Janssen<dreamingforward at gmail.com> wrote:
>>> Anyway... of course patches welcome, yes... ;^)
>> Not really. doctest is for *testing code example in docs*.
> I understand. This is exactly what I was wanting to use it for. As
> Tim says "literate testing" or "executable documentation".
I think you misunderstand: Nick meant, "doctest is only useful for
testing the snippets of code that naturally appear in documentation
meant for people to read." Many people agree with this sentiment, and
find doctest unsuitable for writing comprehensive tests.
> The suggestions I made are for enhancing those two.
> Personally, I don't find unittest very suitable for test-driven
> *development*, although it *is* obviously well-suited for writing
> assurance tests otherwise.
> The key difference, to me, is in that doctest promotes tests being
> written in order to have the *additional functionality* of
> documentation. That makes it fun since your getting "twice the
> value for the cost of one", and that alone is the major item which
> drives test-driven development (IMHO) within the spirit of python,
> otherwise unittest is rather bulky to write in and of itself.
> Does anyone really use unittest outside the context of shop policy?
Many, many people use unittest, namely, all of us that think doctest is
a cute idea, but its many limitations hobble it for serious work.
> Python-ideas mailing list
> Python-ideas at python.org
More information about the Python-ideas