Skip to content

Commit 3d4cf3b

Browse files
[3.14] gh-139951: Test on GC collection disabled if threshold is zero (GH-140304) (#140362)
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 d7dc6bf commit 3d4cf3b

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
@@ -1501,6 +1501,20 @@ def test_indirect_calls_with_gc_disabled(self):
15011501
finally:
15021502
gc.enable()
15031503

1504+
# Ensure that setting *threshold0* to zero disables collection.
1505+
@gc_threshold(0)
1506+
def test_threshold_zero(self):
1507+
junk = []
1508+
i = 0
1509+
detector = GC_Detector()
1510+
while not detector.gc_happened:
1511+
i += 1
1512+
if i > 50000:
1513+
break
1514+
junk.append([]) # this may eventually trigger gc (if it is enabled)
1515+
1516+
self.assertEqual(i, 50001)
1517+
15041518

15051519
class PythonFinalizationTests(unittest.TestCase):
15061520
def test_ast_fini(self):

0 commit comments

Comments
 (0)