summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2019-03-01 09:12:27 (GMT)
committerGitHub <noreply@github.com>2019-03-01 09:12:27 (GMT)
commitd60a79a1015aa26ff7ee3166820ec43558911b60 (patch)
tree42c6cf16ff039e8d7e6bd6b064e0c1ad8bc9fc6d /Lib/test
parent9add4b3317629933d88cf206a24b15e922fa8941 (diff)
downloadcpython-d60a79a1015aa26ff7ee3166820ec43558911b60.zip
cpython-d60a79a1015aa26ff7ee3166820ec43558911b60.tar.gz
cpython-d60a79a1015aa26ff7ee3166820ec43558911b60.tar.bz2
bpo-36155: Check for identity on test_gc.test_get_objects (GH-12116)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_gc.py48
1 files changed, 36 insertions, 12 deletions
diff --git a/Lib/test/test_gc.py b/Lib/test/test_gc.py
index 65e74d4..2dab530 100644
--- a/Lib/test/test_gc.py
+++ b/Lib/test/test_gc.py
@@ -770,21 +770,45 @@ class GCTests(unittest.TestCase):
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()