summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rwxr-xr-xLib/pydoc.py5
-rw-r--r--Lib/test/test_pydoc.py24
2 files changed, 28 insertions, 1 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index fa531e9..9dce079 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -132,7 +132,10 @@ def stripid(text):
return _re_stripid.sub(r'\1', text)
def _is_some_method(obj):
- return inspect.ismethod(obj) or inspect.ismethoddescriptor(obj)
+ return (inspect.isfunction(obj) or
+ inspect.ismethod(obj) or
+ inspect.isbuiltin(obj) or
+ inspect.ismethoddescriptor(obj))
def allmethods(cl):
methods = {}
diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py
index d98a526..542a29b 100644
--- a/Lib/test/test_pydoc.py
+++ b/Lib/test/test_pydoc.py
@@ -395,6 +395,30 @@ class PydocDocTest(unittest.TestCase):
synopsis = pydoc.synopsis(TESTFN, {})
self.assertEqual(synopsis, 'line 1: h\xe9')
+ def test_allmethods(self):
+ # issue 17476: allmethods was no longer returning unbound methods.
+ # This test is a bit fragile in the face of changes to object and type,
+ # but I can't think of a better way to do it without duplicating the
+ # logic of the function under test.
+
+ class TestClass(object):
+ def method_returning_true(self):
+ return True
+
+ # What we expect to get back: everything on object...
+ expected = dict(vars(object))
+ # ...plus our unbound method...
+ expected['method_returning_true'] = TestClass.method_returning_true
+ # ...but not the non-methods on object.
+ del expected['__doc__']
+ del expected['__class__']
+ # inspect resolves descriptors on type into methods, but vars doesn't,
+ # so we need to update __subclasshook__.
+ expected['__subclasshook__'] = TestClass.__subclasshook__
+
+ methods = pydoc.allmethods(TestClass)
+ self.assertDictEqual(methods, expected)
+
class PydocImportTest(unittest.TestCase):