diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_capi.py | 24 | ||||
-rw-r--r-- | Lib/test/test_sys.py | 2 |
2 files changed, 25 insertions, 1 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 diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index 05fbcc1..78da09d 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -1287,7 +1287,7 @@ class SizeofTest(unittest.TestCase): def __sizeof__(self): return int(self) self.assertEqual(sys.getsizeof(OverflowSizeof(sys.maxsize)), - sys.maxsize + self.gc_headsize) + sys.maxsize + self.gc_headsize*2) with self.assertRaises(OverflowError): sys.getsizeof(OverflowSizeof(sys.maxsize + 1)) with self.assertRaises(ValueError): |