diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2021-08-29 14:04:40 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-29 14:04:40 +0300 |
commit | 2a8127cafe1d196f858a3ecabf5f1df3eebf9a12 (patch) | |
tree | ddf073f1752e1dd20aba534964da961aeecf8c95 /Lib/test/test_exceptions.py | |
parent | 07d3d54f4e84b1259b800884b202701f69e408d8 (diff) | |
download | cpython-git-2a8127cafe1d196f858a3ecabf5f1df3eebf9a12.tar.gz |
bpo-25130: Add calls of gc.collect() in tests to support PyPy (GH-28005)
Diffstat (limited to 'Lib/test/test_exceptions.py')
-rw-r--r-- | Lib/test/test_exceptions.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index ce7b86880e..6141f2e8f6 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -656,6 +656,7 @@ class ExceptionTests(unittest.TestCase): except MyException as e: pass obj = None + gc_collect() # For PyPy or other GCs. obj = wr() self.assertIsNone(obj) @@ -667,6 +668,7 @@ class ExceptionTests(unittest.TestCase): except MyException: pass obj = None + gc_collect() # For PyPy or other GCs. obj = wr() self.assertIsNone(obj) @@ -678,6 +680,7 @@ class ExceptionTests(unittest.TestCase): except: pass obj = None + gc_collect() # For PyPy or other GCs. obj = wr() self.assertIsNone(obj) @@ -690,6 +693,7 @@ class ExceptionTests(unittest.TestCase): except: break obj = None + gc_collect() # For PyPy or other GCs. obj = wr() self.assertIsNone(obj) @@ -708,6 +712,7 @@ class ExceptionTests(unittest.TestCase): # 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): @@ -898,6 +903,7 @@ class ExceptionTests(unittest.TestCase): next(g) testfunc(g) g = obj = None + gc_collect() # For PyPy or other GCs. obj = wr() self.assertIsNone(obj) @@ -951,6 +957,7 @@ class ExceptionTests(unittest.TestCase): 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): @@ -1413,6 +1420,7 @@ class ExceptionTests(unittest.TestCase): self.assertNotEqual(wr(), None) else: self.fail("MemoryError not raised") + gc_collect() # For PyPy or other GCs. self.assertEqual(wr(), None) @no_tracing @@ -1433,6 +1441,7 @@ class ExceptionTests(unittest.TestCase): 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): @@ -1453,6 +1462,7 @@ class ExceptionTests(unittest.TestCase): 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) |