summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/test
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2021-09-08 15:08:57 (GMT)
committerGitHub <noreply@github.com>2021-09-08 15:08:57 (GMT)
commit462c1f0403324efc27c11435da12b8d16f5387de (patch)
treee2e37d822e9b777deed2b86e00467a8e5216055f /Lib/unittest/test
parentc081649e6df55203178a44d16bc4c96f9fa2c6a4 (diff)
downloadcpython-462c1f0403324efc27c11435da12b8d16f5387de.zip
cpython-462c1f0403324efc27c11435da12b8d16f5387de.tar.gz
cpython-462c1f0403324efc27c11435da12b8d16f5387de.tar.bz2
[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>
Diffstat (limited to 'Lib/unittest/test')
-rw-r--r--Lib/unittest/test/test_assertions.py3
-rw-r--r--Lib/unittest/test/test_case.py3
2 files changed, 5 insertions, 1 deletions
diff --git a/Lib/unittest/test/test_assertions.py b/Lib/unittest/test/test_assertions.py
index f5e64d6..a0db3423 100644
--- a/Lib/unittest/test/test_assertions.py
+++ b/Lib/unittest/test/test_assertions.py
@@ -2,6 +2,7 @@ import datetime
import warnings
import weakref
import unittest
+from test.support import gc_collect
from itertools import product
@@ -124,8 +125,10 @@ class Test_Assertions(unittest.TestCase):
self.foo()
Foo("test_functional").run()
+ gc_collect() # For PyPy or other GCs.
self.assertIsNone(wr())
Foo("test_with").run()
+ gc_collect() # For PyPy or other GCs.
self.assertIsNone(wr())
def testAssertNotRegex(self):
diff --git a/Lib/unittest/test/test_case.py b/Lib/unittest/test/test_case.py
index b8aca92..3533485 100644
--- a/Lib/unittest/test/test_case.py
+++ b/Lib/unittest/test/test_case.py
@@ -19,7 +19,7 @@ from unittest.test.support import (
TestEquality, TestHashing, LoggingResult, LegacyLoggingResult,
ResultWithNoStartTestRunStopTestRun
)
-from test.support import captured_stderr
+from test.support import captured_stderr, gc_collect
log_foo = logging.getLogger('foo')
@@ -1947,6 +1947,7 @@ test case
for method_name in ('test1', 'test2'):
testcase = TestCase(method_name)
testcase.run()
+ gc_collect() # For PyPy or other GCs.
self.assertEqual(MyException.ninstance, 0)