mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-32265: Classify class and static methods of builtin types. (#4776)
Add types.ClassMethodDescriptorType for unbound class methods.
This commit is contained in:
parent
2e3f570185
commit
3327a2ddf1
6 changed files with 32 additions and 3 deletions
|
@ -858,7 +858,8 @@ class TestClassesAndFunctions(unittest.TestCase):
|
|||
|
||||
attrs = attrs_wo_objs(A)
|
||||
|
||||
self.assertIn(('__new__', 'method', object), attrs, 'missing __new__')
|
||||
self.assertIn(('__new__', 'static method', object), attrs,
|
||||
'missing __new__')
|
||||
self.assertIn(('__init__', 'method', object), attrs, 'missing __init__')
|
||||
|
||||
self.assertIn(('s', 'static method', A), attrs, 'missing static method')
|
||||
|
@ -923,6 +924,18 @@ class TestClassesAndFunctions(unittest.TestCase):
|
|||
if isinstance(builtin, type):
|
||||
inspect.classify_class_attrs(builtin)
|
||||
|
||||
attrs = attrs_wo_objs(bool)
|
||||
self.assertIn(('__new__', 'static method', bool), attrs,
|
||||
'missing __new__')
|
||||
self.assertIn(('from_bytes', 'class method', int), attrs,
|
||||
'missing class method')
|
||||
self.assertIn(('to_bytes', 'method', int), attrs,
|
||||
'missing plain method')
|
||||
self.assertIn(('__add__', 'method', int), attrs,
|
||||
'missing plain method')
|
||||
self.assertIn(('__and__', 'method', bool), attrs,
|
||||
'missing plain method')
|
||||
|
||||
def test_classify_DynamicClassAttribute(self):
|
||||
class Meta(type):
|
||||
def __getattr__(self, name):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue