doctest suggestion

Tim Hochberg tim.hochberg at ieee.org
Fri Sep 28 17:03:11 EDT 2001


Hi all and particularly Tim Peters if your listening,

I like doctest a lot and use it for all of my unit testing. However, I
frequently run into problems when I import a class or function from a module
using "from X import Y". Ys docstring gets run in the current environment
and frequently the doctests fail because they rely on some aspects of Xs
environment.

It seemed like it would be useful to skip tests in docstrings on objects
imported from another module. I threw together a proof of concept of this
which is attached below; this version ignores the docstrings on imported
functions and classes.

So here's the suggestion: I would really like to see this functionality
included in doctest in some way. I'm willing to clean up the changes to my
code and submit a patch if that's appropriate. However, first I wanted
solicit opinions as to whether this approach is a good one or if there's a
more elegant way to go about it:

-tim

Here are the two changed







More information about the Python-list mailing list