summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_capi.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_capi.py')
-rw-r--r--Lib/test/test_capi.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py
index 1ff14e7..e4d2035 100644
--- a/Lib/test/test_capi.py
+++ b/Lib/test/test_capi.py
@@ -539,6 +539,30 @@ class CAPITest(unittest.TestCase):
inst = _testcapi.HeapCTypeWithDict()
self.assertEqual({}, inst.__dict__)
+ def test_heaptype_with_managed_dict(self):
+ inst = _testcapi.HeapCTypeWithManagedDict()
+ inst.foo = 42
+ self.assertEqual(inst.foo, 42)
+ self.assertEqual(inst.__dict__, {"foo": 42})
+
+ inst = _testcapi.HeapCTypeWithManagedDict()
+ self.assertEqual({}, inst.__dict__)
+
+ a = _testcapi.HeapCTypeWithManagedDict()
+ b = _testcapi.HeapCTypeWithManagedDict()
+ a.b = b
+ b.a = a
+ del a, b
+
+ def test_sublclassing_managed_dict(self):
+
+ class C(_testcapi.HeapCTypeWithManagedDict):
+ pass
+
+ i = C()
+ i.spam = i
+ del i
+
def test_heaptype_with_negative_dict(self):
inst = _testcapi.HeapCTypeWithNegativeDict()
inst.foo = 42