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.
This commit is contained in:
Konstantin Lopuhin 2016-09-01 15:43:57 +03:00
parent c3d17659b3
commit 5abb70c8d7
1 changed files with 4 additions and 0 deletions

View File

@ -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")