summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorDong-hee Na <donghee.na92@gmail.com>2017-06-15 14:41:57 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2017-06-15 14:41:57 (GMT)
commite45ea377b8d9ae23893d4587003c6d3e7f54b99a (patch)
treecf9720e2407bd4ce6be4ca7941ab7d801f2719ac /Lib/test
parentcf58dfb44cc11d41ea1473cd7436618b210b8258 (diff)
downloadcpython-e45ea377b8d9ae23893d4587003c6d3e7f54b99a.zip
cpython-e45ea377b8d9ae23893d4587003c6d3e7f54b99a.tar.gz
cpython-e45ea377b8d9ae23893d4587003c6d3e7f54b99a.tar.bz2
bpo-30149: Fix partialmethod without explicit self parameter (#1308) (#1662)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_inspect.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index 37e4511..facf040 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -1989,6 +1989,41 @@ class TestSignatureObject(unittest.TestCase):
('kwargs', ..., int, "var_keyword")),
...))
+ def test_signature_without_self(self):
+ def test_args_only(*args): # NOQA
+ pass
+
+ def test_args_kwargs_only(*args, **kwargs): # NOQA
+ pass
+
+ class A:
+ @classmethod
+ def test_classmethod(*args): # NOQA
+ pass
+
+ @staticmethod
+ def test_staticmethod(*args): # NOQA
+ pass
+
+ f1 = functools.partialmethod((test_classmethod), 1)
+ f2 = functools.partialmethod((test_args_only), 1)
+ f3 = functools.partialmethod((test_staticmethod), 1)
+ f4 = functools.partialmethod((test_args_kwargs_only),1)
+
+ self.assertEqual(self.signature(test_args_only),
+ ((('args', ..., ..., 'var_positional'),), ...))
+ self.assertEqual(self.signature(test_args_kwargs_only),
+ ((('args', ..., ..., 'var_positional'),
+ ('kwargs', ..., ..., 'var_keyword')), ...))
+ self.assertEqual(self.signature(A.f1),
+ ((('args', ..., ..., 'var_positional'),), ...))
+ self.assertEqual(self.signature(A.f2),
+ ((('args', ..., ..., 'var_positional'),), ...))
+ self.assertEqual(self.signature(A.f3),
+ ((('args', ..., ..., 'var_positional'),), ...))
+ self.assertEqual(self.signature(A.f4),
+ ((('args', ..., ..., 'var_positional'),
+ ('kwargs', ..., ..., 'var_keyword')), ...))
@cpython_only
@unittest.skipIf(MISSING_C_DOCSTRINGS,
"Signature information for builtins requires docstrings")