Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update Lib/test/test_inspect/test_inspect.py
(further cosmetics...)
  • Loading branch information
zuo committed Aug 3, 2024
commit fc33fd5cf69e0da73fc5b68460cdf43330b2fa34
14 changes: 6 additions & 8 deletions Lib/test/test_inspect/test_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -1936,11 +1936,8 @@ def static_method(): pass
def a_property(self): pass
class Slotermeyer:
__slots__ = 'a_slot',
attribute_slot = Slotermeyer.__dict__['a_slot']
frame_locals = types.FrameType.f_locals
def function():
pass
a_lambda = lambda: None

# Example builtin method descriptors (non-data descriptors):

Expand All @@ -1965,14 +1962,15 @@ def function():
self.assertFalse(inspect.ismethoddescriptor(Owner.class_method))
self.assertFalse(inspect.ismethoddescriptor(Owner.static_method))
self.assertFalse(inspect.ismethoddescriptor(function))
self.assertFalse(inspect.ismethoddescriptor(a_lambda))
self.assertFalse(inspect.ismethoddescriptor(lambda: None))

# Example builtin data descriptors:

self.assertFalse(
inspect.ismethoddescriptor(Owner.__dict__['a_property']),
'a property is not a method descriptor')

attribute_slot = Slotermeyer.__dict__['a_slot']
if hasattr(types, 'MemberDescriptorType'):
assert inspect.ismemberdescriptor(attribute_slot)
self.assertFalse(
Expand All @@ -1984,6 +1982,7 @@ def function():
inspect.ismethoddescriptor(attribute_slot),
'an attribute slot descriptor is not a method descriptor')

frame_locals = types.FrameType.f_locals
if hasattr(types, 'GetSetDescriptorType'):
assert inspect.isgetsetdescriptor(frame_locals)
self.assertFalse(
Expand Down Expand Up @@ -2167,11 +2166,8 @@ def static_method(): pass
def a_property(self): pass
class Slotermeyer:
__slots__ = 'a_slot',
attribute_slot = Slotermeyer.__dict__['a_slot']
frame_locals = types.FrameType.f_locals
def function():
pass
a_lambda = lambda: None

# Example builtin method descriptors (non-data descriptors):

Expand All @@ -2196,14 +2192,15 @@ def function():
self.assertFalse(inspect.isdatadescriptor(Owner.class_method))
self.assertFalse(inspect.isdatadescriptor(Owner.static_method))
self.assertFalse(inspect.isdatadescriptor(function))
self.assertFalse(inspect.isdatadescriptor(a_lambda))
self.assertFalse(inspect.isdatadescriptor(lambda: None))

# Example builtin data descriptors:

self.assertTrue(
inspect.isdatadescriptor(Owner.__dict__['a_property']),
'a property is a data descriptor')

attribute_slot = Slotermeyer.__dict__['a_slot']
if hasattr(types, 'MemberDescriptorType'):
assert inspect.ismemberdescriptor(attribute_slot)
self.assertTrue(
Expand All @@ -2215,6 +2212,7 @@ def function():
inspect.isdatadescriptor(attribute_slot),
'an attribute slot descriptor is a data descriptor')

frame_locals = types.FrameType.f_locals
if hasattr(types, 'GetSetDescriptorType'):
assert inspect.isgetsetdescriptor(frame_locals)
self.assertTrue(
Expand Down