[Python-authors] Testing source snippets
vceder at canterburyschool.org
Sat Dec 26 06:49:29 CET 2009
At last year's PyCon at the author BoF there was some discussion of the
difficulty of testing code snippets embedded in a book or article's
text. In the course of revising the Quick Python Book for Python 3.x (a
project now finished!) I came up with a little program to doctest my
interactive shell snippets and optionally save them into a text file for
distribution with the book.
I finally got around to cleaning up the code and putting it online, so
if anyone is interested, it's called doctester and lives at
http://bitbucket.org/vceder/doctester, and the wiki documentation there
pretty much explains how it works.
It's really not much, just a way to copy and paste snippets and run
doctest on them, but it did save me a fair amount of time and helped
keep the code examples in my book (I hope) fairly clean.
In looking at it, I can think of about a hundred enhancements that could
be made, but since this project is done, I probably won't work on it for
a while. So if it's of use to anyone else, feel free to take it for what
The Quick Python Book, 2nd Ed, http://www.manning.com/ceder
This time for sure!
-Bullwinkle J. Moose
Vern Ceder, Director of Technology
Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804
vceder at canterburyschool.org; 260-436-0746; FAX: 260-436-5137
More information about the Python-authors