How to test python snippets in my documents?
Lie Ryan
lie.1296 at gmail.com
Tue May 26 11:01:58 EDT 2009
Matthew Wilson wrote:
> I'm using a homemade script to verify some code samples in my
> documentation. Here it is:
>
> #! /usr/bin/env python2.6
>
> # vim: set expandtab ts=4 sw=4 filetype=python:
>
> import doctest, os, sys
>
> def main(s):
> "Run doctest.testfile(s, None)"
>
> return doctest.testfile(s, None)
>
> if __name__ == "__main__":
> for x in sys.argv[1:]:
> print "testing code excerpts in %s..." % x
> print main(x)
>
>
> The script checks all the files listed as arguments. This is OK, but is
> there anything better?
>
maybe glob.glob('*.py')?
More information about the Python-list
mailing list