@@ -16,20 +16,24 @@ class A():
1616 @staticmethod
1717 def s ():
1818 pass
19+
1920
20-
21- def test_sleek_ref ():
22-
23- def counter (_ = None ):
21+ def counter (_ = None ):
2422 if not hasattr (counter , 'count' ):
2523 counter .count = 0
2624 result = counter .count
2725 counter .count += 1
2826 return result
27+
28+
29+ def test_sleek_ref ():
30+
31+
2932
3033 volatile_things = [A (), 1 , 4.5 , 'meow' , u'woof' , [1 , 2 ], (1 , 2 ), {1 : 2 },
31- set ([1 , 2 , 3 ]), sum ]
32- unvolatile_things = [A .s , __builtins__ , list , type , list .append , str .join ]
34+ set ([1 , 2 , 3 ])]
35+ unvolatile_things = [A .s , __builtins__ , list , type , list .append , str .join ,
36+ sum ]
3337
3438 while volatile_things :
3539 volatile_thing = volatile_things .pop ()
@@ -60,4 +64,18 @@ def counter(_=None):
6064 assert sleek_ref () is not None
6165
6266def test_cute_sleek_value_dictionary ():
63- pass
67+ volatile_things = [A (), 1 , 4.5 , 'meow' , u'woof' , [1 , 2 ], (1 , 2 ), {1 : 2 },
68+ set ([1 , 2 , 3 ])]
69+ unvolatile_things = [A .s , __builtins__ , list , type , list .append , str .join ,
70+ sum ]
71+
72+ while volatile_things :
73+ volatile_thing = volatile_things .pop ()
74+ csvd = CuteSleekValueDictionary (counter )
75+ # Using len(csvd) as our key; Just to guarantee we're not running over
76+ # an existing key.
77+ csvd [len (csvd )] = volatile_thing
78+ count = counter ()
79+ del volatile_thing
80+ gc .collect ()
81+ assert counter () == count + 2
0 commit comments