Issue 24298: Fix signature() to properly unwrap wrappers around bound methods

This commit is contained in:
Yury Selivanov 2015-05-27 21:56:53 -04:00
parent 68fe9aa58c
commit 46c759d76d
3 changed files with 24 additions and 0 deletions

View file

@ -1939,6 +1939,19 @@ class TestSignatureObject(unittest.TestCase):
with self.assertRaisesRegex(ValueError, 'invalid method signature'):
self.signature(Test())
def test_signature_wrapped_bound_method(self):
# Issue 24298
class Test:
def m1(self, arg1, arg2=1) -> int:
pass
@functools.wraps(Test().m1)
def m1d(*args, **kwargs):
pass
self.assertEqual(self.signature(m1d),
((('arg1', ..., ..., "positional_or_keyword"),
('arg2', 1, ..., "positional_or_keyword")),
int))
def test_signature_on_classmethod(self):
class Test:
@classmethod