<s> '''<STR_LIT>''' <EOL> import weakref <EOL> import nose . tools <EOL> from python_toolbox import gc_tools <EOL> from python_toolbox . sleek_reffing import ( SleekCallArgs , <EOL> SleekRef , <EOL> SleekRefDied , <EOL> CuteSleekValueDict ) <EOL> from . shared import _is_weakreffable , A , counter <EOL> def test_sleek_ref ( ) : <EOL> '''<STR_LIT>''' <EOL> volatile_things = [ A ( ) , <NUM_LIT:1> , <NUM_LIT> , '<STR_LIT>' , u'<STR_LIT>' , [ <NUM_LIT:1> , <NUM_LIT:2> ] , ( <NUM_LIT:1> , <NUM_LIT:2> ) , { <NUM_LIT:1> : <NUM_LIT:2> } , <EOL> set ( ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ) , ( None , <NUM_LIT:3> , { None : <NUM_LIT:4> } ) ] <EOL> unvolatile_things = [ __builtins__ , type , sum , None ] <EOL> while volatile_things : <EOL> volatile_thing = volatile_things . pop ( ) <EOL> sleek_ref = SleekRef ( volatile_thing , counter ) <EOL> assert sleek_ref ( ) is volatile_thing <EOL> if _is_weakreffable ( volatile_thing ) : <EOL> count = counter ( ) <EOL> del volatile_thing <EOL> gc_tools . collect ( ) <EOL> assert counter ( ) == count + <NUM_LIT:2> <EOL> nose . tools . assert_raises ( SleekRefDied , sleek_ref ) <EOL> else : <EOL> count = counter ( ) <EOL> del volatile_thing <EOL> gc_tools . collect ( ) <EOL> assert counter ( ) == count + <NUM_LIT:1> <EOL> assert sleek_ref ( ) is not None <EOL> while unvolatile_things : <EOL> unvolatile_thing = unvolatile_things . pop ( ) <EOL> sleek_ref = SleekRef ( unvolatile_thing , counter ) <EOL> assert sleek_ref ( ) is unvolatile_thing <EOL> count = counter ( ) <EOL> del unvolatile_thing <EOL> gc_tools . collect ( ) <EOL> assert counter ( ) == count + <NUM_LIT:1> <EOL> sleek_ref ( ) </s>
