[Tutor] Re: problems with doctest: apparent interferance between
tests (LONG)
Brian van den Broek
bvande at po-box.mcgill.ca
Sun Apr 10 18:46:10 CEST 2005
Lee Harr said unto the world upon 2005-04-10 10:21:
>> I have apparent interference between doctests embedded in the
>> docstrings of different methods, and this interference also appears to
>> be influenced by seemingly irrelevant things such as whether the
>> module has a (non-doctest-containing) docstring or not.
>
>
>>
>> I, and what hair I've not yet torn out, would be most grateful for any
>> suggestions.
>
>
>
> I did not see if you have read the doctest.py docstrings... It looks
> (unsurprisingly ;o) to be quite well documented.
>
> It might be a place to start, anyhow.
>
Thanks for the suggestion, Lee. :-)
I was working mostly off of the library reference, rather than the
code itself. (2600+ l.o.c. is a bit past my level of experience.) But,
there's no way to learn but by trying, so I've plunged in.
It is more code than I can currently form a mental model for, but one
line does make me think I cannot understand the observed behaviour.
class DocTest.__init__ takes, among its args, globs, where globs is
documented as:
> globs: The namespace (aka globals) that the examples should
> be run in.
The relevant line of the __init__ method says:
> self.globs = globs.copy()
Thus, if I understand it aright (a shaky bet at best) there should not
be interference between individual doctests. (It seems like each
docstring is parsed to create a DocTest object, and each such object
has its own copy of the appropriate namespace.
So, no joy (yet) :-( Will dig more. Thanks for the push :-)
Best,
Brian vdB
More information about the Tutor
mailing list