summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_weakset.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_weakset.py')
-rw-r--r--Lib/test/test_weakset.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/test/test_weakset.py b/Lib/test/test_weakset.py
index 49a9b5c..9b31d5f 100644
--- a/Lib/test/test_weakset.py
+++ b/Lib/test/test_weakset.py
@@ -5,6 +5,7 @@ from collections import UserString as ustr
from collections.abc import Set, MutableSet
import gc
import contextlib
+from test import support
class Foo:
@@ -48,6 +49,7 @@ class TestWeakSet(unittest.TestCase):
self.assertEqual(len(self.s), len(self.d))
self.assertEqual(len(self.fs), 1)
del self.obj
+ support.gc_collect() # For PyPy or other GCs.
self.assertEqual(len(self.fs), 0)
def test_contains(self):
@@ -57,6 +59,7 @@ class TestWeakSet(unittest.TestCase):
self.assertNotIn(1, self.s)
self.assertIn(self.obj, self.fs)
del self.obj
+ support.gc_collect() # For PyPy or other GCs.
self.assertNotIn(ustr('F'), self.fs)
def test_union(self):
@@ -215,6 +218,7 @@ class TestWeakSet(unittest.TestCase):
self.assertEqual(self.s, dup)
self.assertRaises(TypeError, self.s.add, [])
self.fs.add(Foo())
+ support.gc_collect() # For PyPy or other GCs.
self.assertTrue(len(self.fs) == 1)
self.fs.add(self.obj)
self.assertTrue(len(self.fs) == 1)
@@ -406,6 +410,7 @@ class TestWeakSet(unittest.TestCase):
n1 = len(s)
del it
gc.collect()
+ gc.collect() # For PyPy or other GCs.
n2 = len(s)
# one item may be kept alive inside the iterator
self.assertIn(n1, (0, 1))