summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_gc.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2006-03-07 09:46:03 (GMT)
committerBarry Warsaw <barry@python.org>2006-03-07 09:46:03 (GMT)
commitd3c38ff7f832f60830532524e07a5e11be749d7e (patch)
treec1bb3343d60f4c646a8933057b19206040c2b633 /Lib/test/test_gc.py
parent995acdf308919b61dd94170925e511a926279dbc (diff)
downloadcpython-d3c38ff7f832f60830532524e07a5e11be749d7e.zip
cpython-d3c38ff7f832f60830532524e07a5e11be749d7e.tar.gz
cpython-d3c38ff7f832f60830532524e07a5e11be749d7e.tar.bz2
SF patch #1443865; gc.get_count() added and optional argument 'generation'
added to gc.collect(). Updated docs, unit test, and NEWS entry. (Also, fixed a typo in NEWS.)
Diffstat (limited to 'Lib/test/test_gc.py')
-rw-r--r--Lib/test/test_gc.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_gc.py b/Lib/test/test_gc.py
index fa8659e..ec470c4 100644
--- a/Lib/test/test_gc.py
+++ b/Lib/test/test_gc.py
@@ -219,6 +219,22 @@ def test_del_newclass():
gc.disable()
gc.set_threshold(*thresholds)
+def test_get_count():
+ gc.collect()
+ expect(gc.get_count(), (0, 0, 0), "get_count()")
+ a = dict()
+ expect(gc.get_count(), (1, 0, 0), "get_count()")
+
+def test_collect_generations():
+ gc.collect()
+ a = dict()
+ gc.collect(0)
+ expect(gc.get_count(), (0, 1, 0), "collect(0)")
+ gc.collect(1)
+ expect(gc.get_count(), (0, 0, 1), "collect(1)")
+ gc.collect(2)
+ expect(gc.get_count(), (0, 0, 0), "collect(1)")
+
class Ouch:
n = 0
def __del__(self):
@@ -571,6 +587,8 @@ def test_all():
run_test("finalizers (new class)", test_finalizer_newclass)
run_test("__del__", test_del)
run_test("__del__ (new class)", test_del_newclass)
+ run_test("get_count()", test_get_count)
+ run_test("collect(n)", test_collect_generations)
run_test("saveall", test_saveall)
run_test("trashcan", test_trashcan)
run_test("boom", test_boom)