diff options
author | Yury Selivanov <yselivanov@sprymix.com> | 2014-02-03 07:46:07 (GMT) |
---|---|---|
committer | Yury Selivanov <yselivanov@sprymix.com> | 2014-02-03 07:46:07 (GMT) |
commit | 7d2bfed7a2683e550aec612e3e16691840fda141 (patch) | |
tree | 073ea15c2cd88d8b119d2f020a6282276678a687 /Lib/test/test_inspect.py | |
parent | 45e732de702c8c5d271af926f00c4b29bbe0e42f (diff) | |
download | cpython-7d2bfed7a2683e550aec612e3e16691840fda141.zip cpython-7d2bfed7a2683e550aec612e3e16691840fda141.tar.gz cpython-7d2bfed7a2683e550aec612e3e16691840fda141.tar.bz2 |
inspect.signature: Add (restore) support for builtin classes #20473
Diffstat (limited to 'Lib/test/test_inspect.py')
-rw-r--r-- | Lib/test/test_inspect.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py index efed714..12a315e 100644 --- a/Lib/test/test_inspect.py +++ b/Lib/test/test_inspect.py @@ -2210,6 +2210,32 @@ class TestSignatureObject(unittest.TestCase): self.assertEqual(str(inspect.signature(D)), '(object_or_name, bases, dict)') + @unittest.skipIf(MISSING_C_DOCSTRINGS, + "Signature information for builtins requires docstrings") + def test_signature_on_builtin_class(self): + self.assertEqual(str(inspect.signature(_pickle.Pickler)), + '(file, protocol=None, fix_imports=True)') + + class P(_pickle.Pickler): pass + class EmptyTrait: pass + class P2(EmptyTrait, P): pass + self.assertEqual(str(inspect.signature(P)), + '(file, protocol=None, fix_imports=True)') + self.assertEqual(str(inspect.signature(P2)), + '(file, protocol=None, fix_imports=True)') + + class P3(P2): + def __init__(self, spam): + pass + self.assertEqual(str(inspect.signature(P3)), '(spam)') + + class MetaP(type): + def __call__(cls, foo, bar): + pass + class P4(P2, metaclass=MetaP): + pass + self.assertEqual(str(inspect.signature(P4)), '(foo, bar)') + def test_signature_on_callable_objects(self): class Foo: def __call__(self, a): |