mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
[3.9] bpo-25130: Add calls of gc.collect() in tests to support PyPy (GH-28005). (GH-28028)
(cherry picked from commit 2a8127cafe)
This commit is contained in:
parent
dab74d68e3
commit
330aabbbbe
36 changed files with 143 additions and 15 deletions
|
|
@ -627,6 +627,7 @@ def inner_raising_func():
|
|||
except MyException as e:
|
||||
pass
|
||||
obj = None
|
||||
gc_collect() # For PyPy or other GCs.
|
||||
obj = wr()
|
||||
self.assertIsNone(obj)
|
||||
|
||||
|
|
@ -638,6 +639,7 @@ def inner_raising_func():
|
|||
except MyException:
|
||||
pass
|
||||
obj = None
|
||||
gc_collect() # For PyPy or other GCs.
|
||||
obj = wr()
|
||||
self.assertIsNone(obj)
|
||||
|
||||
|
|
@ -649,6 +651,7 @@ def inner_raising_func():
|
|||
except:
|
||||
pass
|
||||
obj = None
|
||||
gc_collect() # For PyPy or other GCs.
|
||||
obj = wr()
|
||||
self.assertIsNone(obj)
|
||||
|
||||
|
|
@ -661,6 +664,7 @@ def inner_raising_func():
|
|||
except:
|
||||
break
|
||||
obj = None
|
||||
gc_collect() # For PyPy or other GCs.
|
||||
obj = wr()
|
||||
self.assertIsNone(obj)
|
||||
|
||||
|
|
@ -679,6 +683,7 @@ def inner_raising_func():
|
|||
# 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):
|
||||
|
|
@ -869,6 +874,7 @@ def raising_gen():
|
|||
next(g)
|
||||
testfunc(g)
|
||||
g = obj = None
|
||||
gc_collect() # For PyPy or other GCs.
|
||||
obj = wr()
|
||||
self.assertIsNone(obj)
|
||||
|
||||
|
|
@ -922,6 +928,7 @@ def __del__(self):
|
|||
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):
|
||||
|
|
@ -1335,6 +1342,7 @@ def inner():
|
|||
self.assertNotEqual(wr(), None)
|
||||
else:
|
||||
self.fail("MemoryError not raised")
|
||||
gc_collect() # For PyPy or other GCs.
|
||||
self.assertEqual(wr(), None)
|
||||
|
||||
@no_tracing
|
||||
|
|
@ -1355,6 +1363,7 @@ def inner():
|
|||
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):
|
||||
|
|
@ -1375,6 +1384,7 @@ def __del__(self):
|
|||
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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue