26 Dec 2009 06:49
Testing source snippets
Hi everyone, 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 it's worth. Cheers, Vern Ceder The Quick Python Book, 2nd Ed, http://www.manning.com/ceder -- -- This time for sure! -Bullwinkle J. Moose(Continue reading)
RSS Feed