mirror of
https://github.com/python/cpython.git
synced 2025-11-13 23:46:24 +00:00
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
This commit is contained in:
parent
5d2e777787
commit
5f8b0b1fd4
1 changed files with 3 additions and 2 deletions
|
|
@ -302,6 +302,7 @@ from types import StringTypes as _StringTypes
|
||||||
|
|
||||||
from inspect import isclass as _isclass
|
from inspect import isclass as _isclass
|
||||||
from inspect import isfunction as _isfunction
|
from inspect import isfunction as _isfunction
|
||||||
|
from inspect import ismethod as _ismethod
|
||||||
from inspect import ismodule as _ismodule
|
from inspect import ismodule as _ismodule
|
||||||
from inspect import classify_class_attrs as _classify_class_attrs
|
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
|
thisname = prefix + k
|
||||||
if type(v) in _StringTypes:
|
if type(v) in _StringTypes:
|
||||||
f, t = self.runstring(v, thisname)
|
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)
|
f, t = self.rundoc(v, thisname)
|
||||||
else:
|
else:
|
||||||
raise TypeError("Tester.run__test__: values in "
|
raise TypeError("Tester.run__test__: values in "
|
||||||
"dict must be strings, functions "
|
"dict must be strings, functions, methods, "
|
||||||
"or classes; " + `v`)
|
"or classes; " + `v`)
|
||||||
failures = failures + f
|
failures = failures + f
|
||||||
tries = tries + t
|
tries = tries + t
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue