mirror of
https://github.com/python/cpython.git
synced 2026-01-06 07:22:09 +00:00
bpo-36155: Check for identity on test_gc.test_get_objects (GH-12116)
This commit is contained in:
parent
9add4b3317
commit
d60a79a101
1 changed files with 36 additions and 12 deletions
|
|
@ -770,21 +770,45 @@ def test_get_objects(self):
|
|||
gc.collect()
|
||||
l = []
|
||||
l.append(l)
|
||||
self.assertIn(l, gc.get_objects(generation=0))
|
||||
self.assertNotIn(l, gc.get_objects(generation=1))
|
||||
self.assertNotIn(l, gc.get_objects(generation=2))
|
||||
self.assertTrue(
|
||||
any(l is element for element in gc.get_objects(generation=0))
|
||||
)
|
||||
self.assertFalse(
|
||||
any(l is element for element in gc.get_objects(generation=1))
|
||||
)
|
||||
self.assertFalse(
|
||||
any(l is element for element in gc.get_objects(generation=2))
|
||||
)
|
||||
gc.collect(generation=0)
|
||||
self.assertNotIn(l, gc.get_objects(generation=0))
|
||||
self.assertIn(l, gc.get_objects(generation=1))
|
||||
self.assertNotIn(l, gc.get_objects(generation=2))
|
||||
self.assertFalse(
|
||||
any(l is element for element in gc.get_objects(generation=0))
|
||||
)
|
||||
self.assertTrue(
|
||||
any(l is element for element in gc.get_objects(generation=1))
|
||||
)
|
||||
self.assertFalse(
|
||||
any(l is element for element in gc.get_objects(generation=2))
|
||||
)
|
||||
gc.collect(generation=1)
|
||||
self.assertNotIn(l, gc.get_objects(generation=0))
|
||||
self.assertNotIn(l, gc.get_objects(generation=1))
|
||||
self.assertIn(l, gc.get_objects(generation=2))
|
||||
self.assertFalse(
|
||||
any(l is element for element in gc.get_objects(generation=0))
|
||||
)
|
||||
self.assertFalse(
|
||||
any(l is element for element in gc.get_objects(generation=1))
|
||||
)
|
||||
self.assertTrue(
|
||||
any(l is element for element in gc.get_objects(generation=2))
|
||||
)
|
||||
gc.collect(generation=2)
|
||||
self.assertNotIn(l, gc.get_objects(generation=0))
|
||||
self.assertNotIn(l, gc.get_objects(generation=1))
|
||||
self.assertIn(l, gc.get_objects(generation=2))
|
||||
self.assertFalse(
|
||||
any(l is element for element in gc.get_objects(generation=0))
|
||||
)
|
||||
self.assertFalse(
|
||||
any(l is element for element in gc.get_objects(generation=1))
|
||||
)
|
||||
self.assertTrue(
|
||||
any(l is element for element in gc.get_objects(generation=2))
|
||||
)
|
||||
del l
|
||||
gc.collect()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue