[Tutor] Do you use doctests to show API use even when you normally use unit tests?

Alan Gauld alan.gauld at yahoo.co.uk
Sun Apr 26 02:25:31 EDT 2020


On 26/04/2020 05:22, boB Stepp wrote:

> for unit testing as the way to go.  However, they never stop inserting
> doctests into their function and method docstrings.  I am assuming
> that they consider it best practice as to how to document how to use a
> function or method.
> 
> My question is:  Is this what you would consider to be best
> documentation practice?

It's what I do for anything I publish for use by others (not a common
thing these days)  But it is less ambiguous that a simple textual
description, and has the advantage that the user can run the test very
quickly to check the code still works.

They are not a substitute for  a description but they reinforce it,
often removing doubts.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list