summaryrefslogtreecommitdiff
path: root/Lib/test/test_pydoc.py
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2013-03-19 15:03:26 -0700
committerGregory P. Smith <greg@krypto.org>2013-03-19 15:03:26 -0700
commitdd351628942718ede440c8ffe6911f379c9e15b1 (patch)
tree1c0937103d8a7c54f185dfd208a02192da369f04 /Lib/test/test_pydoc.py
parent029273fc903bcbdd689132f153d53004a8aee0b2 (diff)
parent843fae93121ac7ac1088b0521773eff567e7b41c (diff)
downloadcpython-git-dd351628942718ede440c8ffe6911f379c9e15b1.tar.gz
merge heads in 3.2
Diffstat (limited to 'Lib/test/test_pydoc.py')
-rw-r--r--Lib/test/test_pydoc.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py
index c7318ff613..42a4089940 100644
--- a/Lib/test/test_pydoc.py
+++ b/Lib/test/test_pydoc.py
@@ -389,6 +389,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):