mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #29377: Add three new wrappers to types.py (Manuel Krebber).
This commit is contained in:
parent
72268ae1c0
commit
934aba66ef
4 changed files with 49 additions and 0 deletions
|
@ -576,6 +576,24 @@ class TypesTests(unittest.TestCase):
|
|||
self.assertGreater(object.__basicsize__, 0)
|
||||
self.assertGreater(tuple.__itemsize__, 0)
|
||||
|
||||
def test_slot_wrapper_types(self):
|
||||
self.assertIsInstance(object.__init__, types.SlotWrapperType)
|
||||
self.assertIsInstance(object.__str__, types.SlotWrapperType)
|
||||
self.assertIsInstance(object.__lt__, types.SlotWrapperType)
|
||||
self.assertIsInstance(int.__lt__, types.SlotWrapperType)
|
||||
|
||||
def test_method_wrapper_types(self):
|
||||
self.assertIsInstance(object().__init__, types.MethodWrapperType)
|
||||
self.assertIsInstance(object().__str__, types.MethodWrapperType)
|
||||
self.assertIsInstance(object().__lt__, types.MethodWrapperType)
|
||||
self.assertIsInstance((42).__lt__, types.MethodWrapperType)
|
||||
|
||||
def test_method_descriptor_types(self):
|
||||
self.assertIsInstance(str.join, types.MethodDescriptorType)
|
||||
self.assertIsInstance(list.append, types.MethodDescriptorType)
|
||||
self.assertIsInstance(''.join, types.BuiltinMethodType)
|
||||
self.assertIsInstance([].append, types.BuiltinMethodType)
|
||||
|
||||
|
||||
class MappingProxyTests(unittest.TestCase):
|
||||
mappingproxy = types.MappingProxyType
|
||||
|
|
|
@ -36,6 +36,10 @@ MethodType = type(_C()._m)
|
|||
BuiltinFunctionType = type(len)
|
||||
BuiltinMethodType = type([].append) # Same as BuiltinFunctionType
|
||||
|
||||
SlotWrapperType = type(object.__init__)
|
||||
MethodWrapperType = type(object().__str__)
|
||||
MethodDescriptorType = type(str.join)
|
||||
|
||||
ModuleType = type(sys)
|
||||
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue