File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -801,6 +801,26 @@ def __del__(self):
801801 rc , out , err = assert_python_ok ('-c' , code )
802802 self .assertEqual (out .strip (), b'__del__ called' )
803803
804+ def test_gc_debug_stats (self ):
805+ # Checks that debug information is printed to stderr
806+ # when DEBUG_STATS is set.
807+ code = """if 1:
808+ import gc
809+ gc.set_debug(%s)
810+ d = {}
811+ d[(1,2)] = 1
812+ gc.collect()
813+ """
814+ _ , _ , err = assert_python_ok ("-c" , code % "gc.DEBUG_STATS" )
815+ self .assertIn (b"gc: collecting generation" , err )
816+ self .assertIn (b"gc: objects in each generation:" , err )
817+ self .assertIn (b"gc: objects in permanent generation:" , err )
818+ self .assertIn (b"gc: done" , err )
819+ self .assertIn (b"elapsed" , err )
820+
821+ _ , _ , err = assert_python_ok ("-c" , code % "0" )
822+ self .assertNotIn (b"elapsed" , err )
823+
804824 def test_global_del_SystemExit (self ):
805825 code = """if 1:
806826 class ClassWithDel:
You can’t perform that action at this time.
0 commit comments