[3.13] gh-139951: Test on GC collection disabled if threshold is zero (GH-140304) (#140363)

gh-139951: Test on GC collection disabled if threshold is zero (GH-140304)
(cherry picked from commit 5d0abb6971)

Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com>
This commit is contained in:
Miss Islington (bot) 2025-10-21 17:44:23 +02:00 committed by GitHub
parent 7b204ab819
commit 2e2fe26fe6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1524,6 +1524,20 @@ class GCTogglingTests(unittest.TestCase):
finally:
gc.enable()
# Ensure that setting *threshold0* to zero disables collection.
@gc_threshold(0)
def test_threshold_zero(self):
junk = []
i = 0
detector = GC_Detector()
while not detector.gc_happened:
i += 1
if i > 50000:
break
junk.append([]) # this may eventually trigger gc (if it is enabled)
self.assertEqual(i, 50001)
class PythonFinalizationTests(unittest.TestCase):
def test_ast_fini(self):