diff options
author | Raymond Hettinger <python@rcn.com> | 2003-09-02 02:09:05 +0000 |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2003-09-02 02:09:05 +0000 |
commit | a966b68f873848679d6b1ea4ea69537e64921a80 (patch) | |
tree | 31ce60513479b29bbd1e50f8a888002d2a116c12 /Lib/doctest.py | |
parent | b1da8215f6cf58e9b74948f29ac0b5ffee97527f (diff) | |
download | cpython-a966b68f873848679d6b1ea4ea69537e64921a80.tar.gz |
SF 798269: bug fix for doctest (sf bug id: 798254
(Contributed by Alexander Belopolsky.)
Doctest would crash when encountering unbound methods:
class A:
def f(self): pass
class C(A):
g = A.f
Diffstat (limited to 'Lib/doctest.py')
-rw-r--r-- | Lib/doctest.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/doctest.py b/Lib/doctest.py index dcee859970..cff050167f 100644 --- a/Lib/doctest.py +++ b/Lib/doctest.py @@ -302,6 +302,7 @@ from types import StringTypes as _StringTypes from inspect import isclass as _isclass from inspect import isfunction as _isfunction +from inspect import ismethod as _ismethod from inspect import ismodule as _ismodule from inspect import classify_class_attrs as _classify_class_attrs @@ -930,11 +931,11 @@ See doctest.testmod docs for the meaning of optionflags. thisname = prefix + k if type(v) in _StringTypes: f, t = self.runstring(v, thisname) - elif _isfunction(v) or _isclass(v): + elif _isfunction(v) or _isclass(v) or _ismethod(v): f, t = self.rundoc(v, thisname) else: raise TypeError("Tester.run__test__: values in " - "dict must be strings, functions " + "dict must be strings, functions, methods, " "or classes; " + `v`) failures = failures + f tries = tries + t |