[3.10] bpo-25130: Add calls of gc.collect() in tests to support PyPy (GH-28005) (GH-28027)
(cherry picked from commit 2a8127cafe1d196f858a3ecabf5f1df3eebf9a12)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
diff --git a/Lib/test/lock_tests.py b/Lib/test/lock_tests.py
index d69bcc9..dffb7d4 100644
--- a/Lib/test/lock_tests.py
+++ b/Lib/test/lock_tests.py
@@ -3,6 +3,7 @@
"""
import os
+import gc
import sys
import time
from _thread import start_new_thread, TIMEOUT_MAX
@@ -221,6 +222,7 @@ def test_weakref_deleted(self):
lock = self.locktype()
ref = weakref.ref(lock)
del lock
+ gc.collect() # For PyPy or other GCs.
self.assertIsNone(ref())