Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
gh-139951: Test on GC collection disabled if threshold is zero (GH-14…
…0304)

(cherry picked from commit 5d0abb6)

Co-authored-by: Mikhail Efimov <[email protected]>
  • Loading branch information
efimov-mikhail authored and miss-islington committed Oct 20, 2025
commit 6942eb511e790c54b306ad101da9b2ba559289a6
14 changes: 14 additions & 0 deletions Lib/test/test_gc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1501,6 +1501,20 @@ def test_indirect_calls_with_gc_disabled(self):
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):
Expand Down
Loading