forked from Rust-related/RustPython
Update Lib/test/test_class.py from CPython v3.12.0
This commit is contained in:
14
Lib/test/test_class.py
vendored
14
Lib/test/test_class.py
vendored
@@ -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 = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user