Skip to content

Commit e06f5cc

Browse files
committed
Update Lib/test/test_class.py from CPython v3.12.0
1 parent 68dc5ca commit e06f5cc

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎Lib/test/test_class.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,20 @@ def __delattr__(self, *args):
445445
del testme.cardinal
446446
self.assertCallStack([('__delattr__', (testme, "cardinal"))])
447447

448+
def testHasAttrString(self):
449+
import sys
450+
from test.support import import_helper
451+
_testcapi = import_helper.import_module('_testcapi')
452+
453+
class A:
454+
def __init__(self):
455+
self.attr = 1
456+
457+
a = A()
458+
self.assertEqual(_testcapi.object_hasattrstring(a, b"attr"), 1)
459+
self.assertEqual(_testcapi.object_hasattrstring(a, b"noattr"), 0)
460+
self.assertIsNone(sys.exception())
461+
448462
def testDel(self):
449463
x = []
450464

0 commit comments

Comments
 (0)