mirror of
https://github.com/python/cpython.git
synced 2025-10-21 22:22:48 +00:00
inspect.signature: Add support for decorated (wrapped) builtins #20425
This commit is contained in:
parent
b77511da92
commit
76c6c593ed
2 changed files with 18 additions and 3 deletions
|
@ -1655,6 +1655,21 @@ class TestSignatureObject(unittest.TestCase):
|
|||
__call__ = type
|
||||
test_callable(ThisWorksNow())
|
||||
|
||||
@unittest.skipIf(MISSING_C_DOCSTRINGS,
|
||||
"Signature information for builtins requires docstrings")
|
||||
def test_signature_on_decorated_builtins(self):
|
||||
func = _testcapi.docstring_with_signature_with_defaults
|
||||
|
||||
def decorator(func):
|
||||
@functools.wraps(func)
|
||||
def wrapper(*args, **kwargs) -> int:
|
||||
return func(*args, **kwargs)
|
||||
return wrapper
|
||||
|
||||
decorated_func = decorator(func)
|
||||
|
||||
self.assertEqual(inspect.signature(func),
|
||||
inspect.signature(decorated_func))
|
||||
|
||||
def test_signature_on_builtins_no_signature(self):
|
||||
with self.assertRaisesRegex(ValueError, 'no signature found for builtin'):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue