diff options
author | Gregory P. Smith <greg@krypto.org> | 2013-03-19 22:05:52 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@krypto.org> | 2013-03-19 22:05:52 (GMT) |
commit | cca8507758d69f8109ef25cd610218cfb4a3326b (patch) | |
tree | c84a1a4eba43beda4a9b29726bf1d33bc8004bf0 /Lib/test/test_pydoc.py | |
parent | 0408bf9cfb0dac07bf378f10af771fab41ba0d52 (diff) | |
parent | d17ca23828287eb79f28de7c50acf25c29b41e4e (diff) | |
download | cpython-cca8507758d69f8109ef25cd610218cfb4a3326b.zip cpython-cca8507758d69f8109ef25cd610218cfb4a3326b.tar.gz cpython-cca8507758d69f8109ef25cd610218cfb4a3326b.tar.bz2 |
merge heads in 3.3
Diffstat (limited to 'Lib/test/test_pydoc.py')
-rw-r--r-- | Lib/test/test_pydoc.py | 24 |
1 files changed, 24 insertions, 0 deletions
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): |