mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
[3.10] bpo-25130: Add calls of gc.collect() in tests to support PyPy (GH-28005) (GH-28027)
(cherry picked from commit 2a8127cafe)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
c081649e6d
commit
462c1f0403
35 changed files with 139 additions and 13 deletions
|
|
@ -611,6 +611,7 @@ def test_lose_target_ref(self):
|
|||
del c
|
||||
p.start()
|
||||
p.join()
|
||||
gc.collect() # For PyPy or other GCs.
|
||||
self.assertIs(wr(), None)
|
||||
self.assertEqual(q.get(), 5)
|
||||
close_queue(q)
|
||||
|
|
@ -2667,6 +2668,7 @@ def test_release_task_refs(self):
|
|||
self.pool.map(identity, objs)
|
||||
|
||||
del objs
|
||||
gc.collect() # For PyPy or other GCs.
|
||||
time.sleep(DELTA) # let threaded cleanup code run
|
||||
self.assertEqual(set(wr() for wr in refs), {None})
|
||||
# With a process pool, copies of the objects are returned, check
|
||||
|
|
@ -4197,6 +4199,7 @@ def setUp(self):
|
|||
util._finalizer_registry.clear()
|
||||
|
||||
def tearDown(self):
|
||||
gc.collect() # For PyPy or other GCs.
|
||||
self.assertFalse(util._finalizer_registry)
|
||||
util._finalizer_registry.update(self.registry_backup)
|
||||
|
||||
|
|
@ -4208,12 +4211,14 @@ class Foo(object):
|
|||
a = Foo()
|
||||
util.Finalize(a, conn.send, args=('a',))
|
||||
del a # triggers callback for a
|
||||
gc.collect() # For PyPy or other GCs.
|
||||
|
||||
b = Foo()
|
||||
close_b = util.Finalize(b, conn.send, args=('b',))
|
||||
close_b() # triggers callback for b
|
||||
close_b() # does nothing because callback has already been called
|
||||
del b # does nothing because callback has already been called
|
||||
gc.collect() # For PyPy or other GCs.
|
||||
|
||||
c = Foo()
|
||||
util.Finalize(c, conn.send, args=('c',))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue