[Zope3-dev] Re: doctests in *.txt files

Mark McEahern marklists at mceahern.com
Sat Mar 27 10:38:07 EST 2004


Garrett Smith wrote:

> Nevermind...I just found:
>
>   zope/interfaces/adapter.txt
>
> Btw, anyone interested in a powerful idea for software 
> testing/development, take a look at this.


At PyCON, Jim Fulton mentioned that it would be nice to add to test.py a 
facility for finding/running pure text doctest-based tests.  Here's a 
simple method for turning a text file into a doctest.DocTestSuite:

def suiteFromText(name):
    basename = os.path.basename(name)
    prefix, ext = os.path.splitext(basename)
    m = new.module(prefix)
    m.__doc__ = file(name).read()
    m.__file__ = name
    return doctest.DocTestSuite(m)

The simplest thing that could possibly work would be to add 
suiteFromText() to test.py as well as an option like --text to find/run 
*.txt in the directories/packages specified by the other options.

Does this smell too hackish?

Jim also mentioned that it would be nice to refactor test.py so that it 
could be generally useful outside of Zope3.  I'd like to tackle that if 
no one else is working on it.

Thanks,

// m



More information about the Zope3-dev mailing list