[Patches] [ python-Patches-466616 ] Exclude imported items from doctest

noreply@sourceforge.net noreply@sourceforge.net
Mon, 01 Oct 2001 21:30:43 -0700


Patches item #466616, was opened at 2001-09-30 13:31
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=466616&group_id=5470

Category: Library (Lib)
Group: None
Status: Closed
Resolution: Fixed
Priority: 5
Submitted By: Tim Hochberg (tim-hochberg)
Assigned to: Tim Peters (tim_one)
Summary: Exclude imported items from doctest

Initial Comment:

With this patch, functions and classes that have been 
imported into a module are not scanned for docstrings 
to test by testmod. These tests frequently fail 
because they end up using the wrong globals.

The method used to test whether a function or class is 
from a given module _does_ work with Jython (tested on 
2.1a3). However, the current CVS version of doctest 
doesn't work with Jython, so I tested this with the a 
version of doctest from python 2.1 that had the same 
mods that are in the enclosed patch.

Tests were added to the docstring of Tester.rundict to 
assure that the exclusion works properly. An update to 
the library documentation for doctest will be 
posted "real soon now".


----------------------------------------------------------------------

>Comment By: Tim Hochberg (tim-hochberg)
Date: 2001-10-01 21:30

Message:
Logged In: YES 
user_id=294744

Great to here it, but...  Arghhh!

Somewhere in preparing the patch and moving back and forth 
between CVS and 2.1 I dropped a line from the patch. And 
it's the line that actually makes it work. I'm too tired to 
prepare a patch tonight, but rundict should be invoked 
as "f, t = tester.rundict(m.__dict__, name, m)" in testmod 
(the 'm' is added). Otherwise the patch doesn't really do 
anything in normal usage, which is silly. Sigh.

I can prepare a patch tomorrow if you like.


----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2001-10-01 20:55

Message:
Logged In: YES 
user_id=31435

Nice work, Tim.  I checked this in after fiddling the tests 
for "is a function" and "is a class" (here and elsewhere in 
doctest) -- that's not as simple in 2.2 as it used to be, 
and doctest wasn't smart enough without the patch either 
(although you probably wouldn't notice without testing new-
style classes).

Lib/doctest.py; new revision: 1.18
Lib/test/test_pyclbr.py; new revision: 1.5
Misc/NEWS; new revision: 1.266

----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2001-10-01 16:24

Message:
Logged In: YES 
user_id=31435

Thanks, Tim!  I assigned this to me.  I'm afraid Jython has 
some catching up to do so that the new "do the right thing 
with future-stmt imports in simulated shells" tricks work 
there too.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=466616&group_id=5470