mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
gh-118402: Fix inspect.signature() for functools.cmp_to_key() result (GH-118427)
This commit is contained in:
parent
02887c6428
commit
17a8af9508
3 changed files with 23 additions and 3 deletions
|
|
@ -947,8 +947,13 @@ class TestCmpToKey:
|
|||
@unittest.skipIf(support.MISSING_C_DOCSTRINGS,
|
||||
"Signature information for builtins requires docstrings")
|
||||
def test_cmp_to_signature(self):
|
||||
self.assertEqual(str(Signature.from_callable(self.cmp_to_key)),
|
||||
'(mycmp)')
|
||||
sig = Signature.from_callable(self.cmp_to_key)
|
||||
self.assertEqual(str(sig), '(mycmp)')
|
||||
def mycmp(x, y):
|
||||
return y - x
|
||||
sig = Signature.from_callable(self.cmp_to_key(mycmp))
|
||||
self.assertEqual(str(sig), '(obj)')
|
||||
|
||||
|
||||
|
||||
@unittest.skipUnless(c_functools, 'requires the C _functools module')
|
||||
|
|
@ -1864,9 +1869,10 @@ class TestLRU:
|
|||
self.assertIsNone(ref())
|
||||
|
||||
def test_common_signatures(self):
|
||||
def orig(): ...
|
||||
def orig(a, /, b, c=True): ...
|
||||
lru = self.module.lru_cache(1)(orig)
|
||||
|
||||
self.assertEqual(str(Signature.from_callable(lru)), '(a, /, b, c=True)')
|
||||
self.assertEqual(str(Signature.from_callable(lru.cache_info)), '()')
|
||||
self.assertEqual(str(Signature.from_callable(lru.cache_clear)), '()')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue