Update Lib/test/test_class.py from CPython v3.12.0

This commit is contained in:
NakanoMiku
2023-11-23 16:31:27 +08:00
parent 68dc5ca052
commit e06f5ccfe4

View File

@@ -445,6 +445,20 @@ class ClassTests(unittest.TestCase):
del testme.cardinal
self.assertCallStack([('__delattr__', (testme, "cardinal"))])
def testHasAttrString(self):
import sys
from test.support import import_helper
_testcapi = import_helper.import_module('_testcapi')
class A:
def __init__(self):
self.attr = 1
a = A()
self.assertEqual(_testcapi.object_hasattrstring(a, b"attr"), 1)
self.assertEqual(_testcapi.object_hasattrstring(a, b"noattr"), 0)
self.assertIsNone(sys.exception())
def testDel(self):
x = []