File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1875,10 +1875,22 @@ def test_gc_tracking(self):
18751875 self .assertFalse (gc .is_tracked (frozendict .fromkeys ('ab' , 1 )))
18761876 self .assertFalse (gc .is_tracked (frozendict ({1 : 2 }) | {3 : 4 }))
18771877
1878+ # a tuple is tracked by the GC when created; a collection untracks
1879+ # it if it contains no gc-tracked items, and then it can never be
1880+ # tracked again, so the frozendict is left untracked as well
1881+ t = (2 ,)
1882+ gc .collect ()
1883+ self .assertFalse (gc .is_tracked (t ))
1884+ self .assertFalse (gc .is_tracked (frozendict ({1 : t })))
1885+
18781886 self .assertTrue (gc .is_tracked (frozendict ({1 : [2 ]})))
1887+ class Key :
1888+ pass
1889+ self .assertTrue (gc .is_tracked (frozendict ({Key (): 1 })))
18791890 # subclasses can create reference cycles, they are always tracked
18801891 self .assertTrue (gc .is_tracked (FrozenDict ({1 : 2 })))
18811892
1893+ def test_gc_collect_reference_cycle (self ):
18821894 # a reference cycle through a tracked frozendict is collectable
18831895 class Obj :
18841896 pass
You can’t perform that action at this time.
0 commit comments