Skip to content

Commit 2e2fe26

Browse files
[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 5d0abb6) Co-authored-by: Mikhail Efimov <[email protected]>
1 parent 7b204ab commit 2e2fe26

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Lib/test/test_gc.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,6 +1524,20 @@ def test_indirect_calls_with_gc_disabled(self):
15241524
finally:
15251525
gc.enable()
15261526

1527+
# Ensure that setting *threshold0* to zero disables collection.
1528+
@gc_threshold(0)
1529+
def test_threshold_zero(self):
1530+
junk = []
1531+
i = 0
1532+
detector = GC_Detector()
1533+
while not detector.gc_happened:
1534+
i += 1
1535+
if i > 50000:
1536+
break
1537+
junk.append([]) # this may eventually trigger gc (if it is enabled)
1538+
1539+
self.assertEqual(i, 50001)
1540+
15271541

15281542
class PythonFinalizationTests(unittest.TestCase):
15291543
def test_ast_fini(self):

0 commit comments

Comments
 (0)