mirror of
https://github.com/python/cpython.git
synced 2025-10-21 22:22:48 +00:00
inspect.signature: Support classes without user-defined __init__/__new__ #20308
This commit is contained in:
parent
7aedea40d6
commit
e7dcc5e97a
3 changed files with 28 additions and 0 deletions
|
@ -2045,6 +2045,20 @@ class TestSignatureObject(unittest.TestCase):
|
|||
('bar', 2, ..., "keyword_only")),
|
||||
...))
|
||||
|
||||
# Test classes without user-defined __init__ or __new__
|
||||
class C: pass
|
||||
self.assertEqual(str(inspect.signature(C)), '()')
|
||||
class D(C): pass
|
||||
self.assertEqual(str(inspect.signature(D)), '()')
|
||||
|
||||
# Test meta-classes without user-defined __init__ or __new__
|
||||
class C(type): pass
|
||||
self.assertEqual(str(inspect.signature(C)),
|
||||
'(object_or_name, bases, dict)')
|
||||
class D(C): pass
|
||||
self.assertEqual(str(inspect.signature(D)),
|
||||
'(object_or_name, bases, dict)')
|
||||
|
||||
def test_signature_on_callable_objects(self):
|
||||
class Foo:
|
||||
def __call__(self, a):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue