[Jython-checkins] jython: Switch to using test_support.gc_collect for test_weakset test, which should
darjus.loktevic
jython-checkins at python.org
Fri Mar 18 19:49:25 EDT 2016
https://hg.python.org/jython/rev/36edf877d361
changeset: 7917:36edf877d361
user: Darjus Loktevic <darjus at gmail.com>
date: Sat Mar 19 10:49:19 2016 +1100
summary:
Switch to using test_support.gc_collect for test_weakset test, which should work much better for regrtest on slower machines
files:
Lib/test/test_weakset.py | 30 ++++++++++++---------------
1 files changed, 13 insertions(+), 17 deletions(-)
diff --git a/Lib/test/test_weakset.py b/Lib/test/test_weakset.py
--- a/Lib/test/test_weakset.py
+++ b/Lib/test/test_weakset.py
@@ -83,7 +83,7 @@
self.assertEqual(len(self.s), len(self.d))
self.assertEqual(len(self.fs), 1)
del self.obj
- gc.collect()
+ test_support.gc_collect()
# len of weak collections is eventually consistent on
# Jython. In practice this does not matter because of the
# nature of weaksets - we cannot rely on what happens in the
@@ -97,7 +97,7 @@
self.assertNotIn(1, self.s)
self.assertIn(self.obj, self.fs)
del self.obj
- gc.collect()
+ test_support.gc_collect()
self.assertNotIn(SomeClass('F'), self.fs)
def test_union(self):
@@ -112,10 +112,10 @@
c = C(self.items2)
self.assertEqual(self.s.union(c), x)
del c
- gc.collect()
+ test_support.gc_collect()
self.assertEqual(len(list(u)), len(list(self.items)) + len(list(self.items2)))
self.items2.pop()
- gc.collect()
+ test_support.gc_collect()
self.assertEqual(len(list(u)), len(list(self.items)) + len(list(self.items2)))
def test_or(self):
@@ -135,7 +135,7 @@
self.assertEqual(i.intersection(C(self.items)), x)
self.assertEqual(len(i), len(self.items2))
self.items2.pop()
- gc.collect()
+ test_support.gc_collect()
self.assertEqual(len(list(i)), len(list(self.items2)))
def test_isdisjoint(self):
@@ -169,7 +169,7 @@
self.assertRaises(TypeError, self.s.symmetric_difference, [[]])
self.assertEqual(len(i), len(self.items) + len(self.items2))
self.items2.pop()
- gc.collect()
+ test_support.gc_collect()
self.assertEqual(len(list(i)), len(list(self.items)) + len(list(self.items2)))
def test_xor(self):
@@ -258,7 +258,7 @@
if not test_support.is_jython: # Jython/JVM can weakly reference list and other objects
self.assertRaises(TypeError, self.s.add, [])
self.fs.add(Foo())
- gc.collect() # CPython assumes Foo() went out of scope and was collected, so ensure the same
+ test_support.gc_collect() # CPython assumes Foo() went out of scope and was collected, so ensure the same
self.assertEqual(len(list(self.fs)), 1)
self.fs.add(self.obj)
self.assertEqual(len(list(self.fs)), 1)
@@ -391,7 +391,7 @@
next(it) # Trigger internal iteration
# Destroy an item
del items[-1]
- gc.collect() # just in case
+ test_support.gc_collect() # just in case
# We have removed either the first consumed items, or another one
self.assertIn(len(list(it)), [len(items), len(items) - 1])
del it
@@ -410,13 +410,12 @@
next(it)
# Schedule an item for removal and recreate it
u = SomeClass(str(items.pop()))
- gc.collect() # just in case
+ test_support.gc_collect() # just in case
yield u
finally:
it = None # should commit all removals
- for _ in xrange(10):
- gc.collect()
+ test_support.gc_collect()
with testcontext() as u:
self.assertNotIn(u, s)
@@ -440,8 +439,7 @@
s = WeakSet(items)
del items
# do some gc
- for _ in xrange(10):
- gc.collect()
+ test_support.gc_collect()
it = iter(s)
try:
next(it)
@@ -449,14 +447,12 @@
pass
# do some gc
- for _ in xrange(10):
- gc.collect()
+ test_support.gc_collect()
n1 = len(s)
del it
# do some gc
- for _ in xrange(10):
- gc.collect()
+ test_support.gc_collect()
n2 = len(s)
# one item may be kept alive inside the iterator
--
Repository URL: https://hg.python.org/jython
More information about the Jython-checkins
mailing list