[ python-Bugs-764504 ] doctest fails with TypeError

SourceForge.net noreply at sourceforge.net
Sun Aug 8 05:06:28 CEST 2004


Bugs item #764504, was opened at 2003-07-02 06:30
Message generated for change (Comment added) made by tim_one
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=764504&group_id=5470

Category: Python Library
Group: Python 2.4
>Status: Closed
>Resolution: Fixed
Priority: 3
Submitted By: Mark J (average)
>Assigned to: Tim Peters (tim_one)
Summary: doctest fails with TypeError

Initial Comment:
#mymod.py:

class base(dict):
  myupdate = dict.update    #FINE
  def myfunc(self):
    pass
                                                      
                         
class derive(base):
  myname = base.myfunc   #FAILS
                                                      
                         
import doctest, mymod
doctest.testmod(mymod)
                                                      
                         
******

$ python2.3b2 mymod.py
Traceback (most recent call last):
  File "mymod.py", line 8, in ?
    import doctest, mymod
  File "/home/me/mymod.py", line 9, in ?
    doctest.testmod(mymod)
  File "/usr/local/lib/python2.3/doctest.py", line
1137, in testmod
    f, t = tester.rundict(m.__dict__, name, m)
  File "/usr/local/lib/python2.3/doctest.py", line 900,
in rundict
    f2, t2 = self.__runone(value, name + "." + thisname)
  File "/usr/local/lib/python2.3/doctest.py", line
1061, in __runone
    return self.rundoc(target, name)
  File "/usr/local/lib/python2.3/doctest.py", line 820,
in rundoc
    f2, t2 = self.run__test__(d, name)
  File "/usr/local/lib/python2.3/doctest.py", line 929,
in run__test__
    raise TypeError("Tester.run__test__: values in "
TypeError: Tester.run__test__: values in dict must be
strings, functions or classes; <unbound method base.myfunc>

******

Does not appear to be specific to Python v2.3.

Thanks!

Mark

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

>Comment By: Tim Peters (tim_one)
Date: 2004-08-07 23:06

Message:
Logged In: YES 
user_id=31435

The example no longer complains in 2.4 doctest.py, so closing 
as Fixed.

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

Comment By: Raymond Hettinger (rhettinger)
Date: 2003-07-17 02:27

Message:
Logged In: YES 
user_id=80475

Agreed.  There is no compelling use case for changing this in 
Py2.3.  Marking as postponed.  For Py2.4, there will be plenty 
of time for merging/improving the underlying search 
behaviors. 

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

Comment By: Tim Peters (tim_one)
Date: 2003-07-16 17:08

Message:
Logged In: YES 
user_id=31435

If it has to be fixed <wink>, the only principle I can conjure 
up is that redundant testing is a waste of time and 
surprising.  On that ground, in the specific example I'd rather 
skip it, since if the thing had a doctest, it would be most 
natural to run it from base.myfunc.__doc__.

If you're feeling more ambitious, I recently slammed in some 
useful doctest extensions from Jim Fulton.  As I know you've 
already discovered, there are some warts.  The deepest wart 
isn't obvious:  Jim's extensions use their own ways of finding 
doctests to run.  It would be good if everthing used the same 
ways of finding doctests to run.  This bug report shows that 
doctest's old ways don't always work.  It's unknown in how 
many situations the new ways don't work, and/or deliver 
different results.

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

Comment By: Raymond Hettinger (rhettinger)
Date: 2003-07-09 01:48

Message:
Logged In: YES 
user_id=80475

Tim, would you like me to fix this one by searching the 
unbound method or by skipping the unbound method?

Since classes are searched recursively, it may be reasonable 
to search the unbound method.   However, imports are not 
searched, so there is a precedent for skipping it.

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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=764504&group_id=5470


More information about the Python-bugs-list mailing list