bpo-25130: Add calls of gc.collect() in tests to support PyPy (GH-28005)

This commit is contained in:
Serhiy Storchaka 2021-08-29 14:04:40 +03:00 committed by GitHub
parent 07d3d54f4e
commit 2a8127cafe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 144 additions and 14 deletions

View file

@ -656,6 +656,7 @@ class ExceptionTests(unittest.TestCase):
except MyException as e:
pass
obj = None
gc_collect() # For PyPy or other GCs.
obj = wr()
self.assertIsNone(obj)
@ -667,6 +668,7 @@ class ExceptionTests(unittest.TestCase):
except MyException:
pass
obj = None
gc_collect() # For PyPy or other GCs.
obj = wr()
self.assertIsNone(obj)
@ -678,6 +680,7 @@ class ExceptionTests(unittest.TestCase):
except:
pass
obj = None
gc_collect() # For PyPy or other GCs.
obj = wr()
self.assertIsNone(obj)
@ -690,6 +693,7 @@ class ExceptionTests(unittest.TestCase):
except:
break
obj = None
gc_collect() # For PyPy or other GCs.
obj = wr()
self.assertIsNone(obj)
@ -708,6 +712,7 @@ class ExceptionTests(unittest.TestCase):
# must clear the latter manually for our test to succeed.
e.__context__ = None
obj = None
gc_collect() # For PyPy or other GCs.
obj = wr()
# guarantee no ref cycles on CPython (don't gc_collect)
if check_impl_detail(cpython=False):
@ -898,6 +903,7 @@ class ExceptionTests(unittest.TestCase):
next(g)
testfunc(g)
g = obj = None
gc_collect() # For PyPy or other GCs.
obj = wr()
self.assertIsNone(obj)
@ -951,6 +957,7 @@ class ExceptionTests(unittest.TestCase):
raise Exception(MyObject())
except:
pass
gc_collect() # For PyPy or other GCs.
self.assertEqual(e, (None, None, None))
def test_raise_does_not_create_context_chain_cycle(self):
@ -1413,6 +1420,7 @@ class ExceptionTests(unittest.TestCase):
self.assertNotEqual(wr(), None)
else:
self.fail("MemoryError not raised")
gc_collect() # For PyPy or other GCs.
self.assertEqual(wr(), None)
@no_tracing
@ -1433,6 +1441,7 @@ class ExceptionTests(unittest.TestCase):
self.assertNotEqual(wr(), None)
else:
self.fail("RecursionError not raised")
gc_collect() # For PyPy or other GCs.
self.assertEqual(wr(), None)
def test_errno_ENOTDIR(self):
@ -1453,6 +1462,7 @@ class ExceptionTests(unittest.TestCase):
with support.catch_unraisable_exception() as cm:
del obj
gc_collect() # For PyPy or other GCs.
self.assertEqual(cm.unraisable.object, BrokenDel.__del__)
self.assertIsNotNone(cm.unraisable.exc_traceback)