From 5abb70c8d71365adbf3a035b1f6d07f5fbbbf446 Mon Sep 17 00:00:00 2001 From: Konstantin Lopuhin Date: Thu, 1 Sep 2016 15:43:57 +0300 Subject: [PATCH] Fix test_weakkeycache on PyPy: run gc.collect() One gc.collect() seems to be enough, but it's more reliable to run it several times (at most 100), until all objects are collected. --- tests/test_utils_python.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_utils_python.py b/tests/test_utils_python.py index 9a0cc975d..e22bd8eb6 100644 --- a/tests/test_utils_python.py +++ b/tests/test_utils_python.py @@ -1,3 +1,4 @@ +import gc import functools import operator import unittest @@ -144,6 +145,9 @@ class UtilsPythonTestCase(unittest.TestCase): self.assertNotEqual(v, wk[_Weakme()]) self.assertEqual(v, wk[k]) del k + for _ in range(100): + if wk._weakdict: + gc.collect() self.assertFalse(len(wk._weakdict)) @unittest.skipUnless(six.PY2, "deprecated function")