<s> '''<STR_LIT>''' <EOL> from python_toolbox . freezing import FreezerProperty , Freezer <EOL> from python_toolbox import caching <EOL> def test_lone_freezer_property ( ) : <EOL> '''<STR_LIT>''' <EOL> class A ( object ) : <EOL> lone_freezer = FreezerProperty ( ) <EOL> a = A ( ) <EOL> assert isinstance ( a . lone_freezer , Freezer ) <EOL> assert a . lone_freezer . frozen == <NUM_LIT:0> <EOL> with a . lone_freezer : <EOL> assert a . lone_freezer . frozen <EOL> def test_decorate_happy_freezer_property ( ) : <EOL> '''<STR_LIT>''' <EOL> class C ( object ) : <EOL> decorate_happy_freeze_counter = caching . CachedProperty ( <NUM_LIT:0> ) <EOL> decorate_happy_thaw_counter = caching . CachedProperty ( <NUM_LIT:0> ) <EOL> decorate_happy_freezer = FreezerProperty ( ) <EOL> @ decorate_happy_freezer . on_freeze <EOL> def increment_decorate_happy_freeze_counter ( self ) : <EOL> self . decorate_happy_freeze_counter += <NUM_LIT:1> <EOL> @ decorate_happy_freezer . on_thaw <EOL> def increment_decorate_happy_thaw_counter ( self ) : <EOL> self . decorate_happy_thaw_counter += <NUM_LIT:1> <EOL> b = C ( ) <EOL> assert b . decorate_happy_freezer . frozen == <NUM_LIT:0> <EOL> assert b . decorate_happy_freeze_counter == <NUM_LIT:0> <EOL> assert b . decorate_happy_thaw_counter == <NUM_LIT:0> <EOL> with b . decorate_happy_freezer : <EOL> assert b . decorate_happy_freezer . frozen == <NUM_LIT:1> <EOL> assert b . decorate_happy_freeze_counter == <NUM_LIT:1> <EOL> assert b . decorate_happy_thaw_counter == <NUM_LIT:0> <EOL> with b . decorate_happy_freezer : <EOL> assert b . decorate_happy_freezer . frozen == <NUM_LIT:2> <EOL> assert b . decorate_happy_freeze_counter == <NUM_LIT:1> <EOL> assert b . decorate_happy_thaw_counter == <NUM_LIT:0> <EOL> assert b . decorate_happy_freezer . frozen == <NUM_LIT:1> <EOL> assert b . decorate_happy_freeze_counter == <NUM_LIT:1> <EOL> assert b . decorate_happy_thaw_counter == <NUM_LIT:0> <EOL> assert b . decorate_happy_freezer . frozen == <NUM_LIT:0> <EOL> assert b . decorate_happy_freeze_counter == <NUM_LIT:1> <EOL> assert b . decorate_happy_thaw_counter == <NUM_LIT:1> <EOL> with b . decorate_happy_freezer : <EOL> assert b . decorate_happy_freezer . frozen == <NUM_LIT:1> <EOL> assert b . decorate_happy_freeze_counter == <NUM_LIT:2> <EOL> assert b . decorate_happy_thaw_counter == <NUM_LIT:1> <EOL> assert b . decorate_happy_freezer . frozen == <NUM_LIT:0> <EOL> assert b . decorate_happy_freeze_counter == <NUM_LIT:2> <EOL> assert b . decorate_happy_thaw_counter == <NUM_LIT:2> <EOL> def test_argument_happy_freezer_property ( ) : <EOL> '''<STR_LIT>''' <EOL> class C ( object ) : <EOL> argument_happy_freeze_counter = caching . CachedProperty ( <NUM_LIT:0> ) <EOL> argument_happy_thaw_counter = caching . CachedProperty ( <NUM_LIT:0> ) <EOL> def increment_argument_happy_freeze_counter ( self ) : <EOL> self . argument_happy_freeze_counter += <NUM_LIT:1> <EOL> def increment_argument_happy_thaw_counter ( self ) : <EOL> self . argument_happy_thaw_counter += <NUM_LIT:1> <EOL> argument_happy_freezer = FreezerProperty ( <EOL> on_freeze = increment_argument_happy_freeze_counter , <EOL> on_thaw = increment_argument_happy_thaw_counter , <EOL> name = '<STR_LIT>' <EOL> ) <EOL> c = C ( ) <EOL> assert c . argument_happy_freezer . frozen == <NUM_LIT:0> <EOL> assert c . argument_happy_freeze_counter == <NUM_LIT:0> <EOL> assert c . argument_happy_thaw_counter == <NUM_LIT:0> <EOL> with c . argument_happy_freezer : <EOL> assert c . argument_happy_freezer . frozen == <NUM_LIT:1> <EOL> assert c . argument_happy_freeze_counter == <NUM_LIT:1> <EOL> assert c . argument_happy_thaw_counter == <NUM_LIT:0> <EOL> with c . argument_happy_freezer : <EOL> assert c . argument_happy_freezer . frozen == <NUM_LIT:2> <EOL> assert c . argument_happy_freeze_counter == <NUM_LIT:1> <EOL> assert c . argument_happy_thaw_counter == <NUM_LIT:0> <EOL> assert c . argument_happy_freezer . frozen == <NUM_LIT:1> <EOL> assert c . argument_happy_freeze_counter == <NUM_LIT:1> <EOL> assert c . argument_happy_thaw_counter == <NUM_LIT:0> <EOL> assert c . argument_happy_freezer . frozen == <NUM_LIT:0> <EOL> assert c . argument_happy_freeze_counter == <NUM_LIT:1> <EOL> assert c . argument_happy_thaw_counter == <NUM_LIT:1> <EOL> with c . argument_happy_freezer : <EOL> assert c . argument_happy_freezer . frozen == <NUM_LIT:1> <EOL> assert c . argument_happy_freeze_counter == <NUM_LIT:2> <EOL> assert c . argument_happy_thaw_counter == <NUM_LIT:1> <EOL> assert c . argument_happy_freezer . frozen == <NUM_LIT:0> <EOL> assert c . argument_happy_freeze_counter == <NUM_LIT:2> <EOL> assert c . argument_happy_thaw_counter == <NUM_LIT:2> <EOL> def test_mix_freezer_property ( ) : <EOL> '''<STR_LIT>''' <EOL> class D ( object ) : <EOL> mix_freeze_counter = caching . CachedProperty ( <NUM_LIT:0> ) <EOL> mix_thaw_counter = caching . CachedProperty ( <NUM_LIT:0> ) <EOL> def increment_mix_freeze_counter ( self ) : <EOL> self . mix_freeze_counter += <NUM_LIT:1> <EOL> mix_freezer = FreezerProperty ( on_freeze = increment_mix_freeze_counter ) <EOL> @ mix_freezer . on_thaw <EOL> def increment_mix_thaw_counter ( self ) : <EOL> self . mix_thaw_counter += <NUM_LIT:1> <EOL> d = D ( ) <EOL> assert d . mix_freezer . frozen == <NUM_LIT:0> <EOL> assert d . mix_freeze_counter == <NUM_LIT:0> <EOL> assert d . mix_thaw_counter == <NUM_LIT:0> <EOL> with d . mix_freezer : <EOL> assert d . mix_freezer . frozen == <NUM_LIT:1> <EOL> assert d . mix_freeze_counter == <NUM_LIT:1> <EOL> assert d . mix_thaw_counter == <NUM_LIT:0> <EOL> with d . mix_freezer : <EOL> assert d . mix_freezer . frozen == <NUM_LIT:2> <EOL> assert d . mix_freeze_counter == <NUM_LIT:1> <EOL> assert d . mix_thaw_counter == <NUM_LIT:0> <EOL> assert d . mix_freezer . frozen == <NUM_LIT:1> <EOL> assert d . mix_freeze_counter == <NUM_LIT:1> <EOL> assert d . mix_thaw_counter == <NUM_LIT:0> <EOL> assert d . mix_freezer . frozen == <NUM_LIT:0> <EOL> assert d . mix_freeze_counter == <NUM_LIT:1> <EOL> assert d . mix_thaw_counter == <NUM_LIT:1> <EOL> with d . mix_freezer : <EOL> assert d . mix_freezer . frozen == <NUM_LIT:1> <EOL> assert d . mix_freeze_counter == <NUM_LIT:2> <EOL> assert d . mix_thaw_counter == <NUM_LIT:1> <EOL> assert d . mix_freezer . frozen == <NUM_LIT:0> <EOL> assert d . mix_freeze_counter == <NUM_LIT:2> <EOL> assert d . mix_thaw_counter == <NUM_LIT:2> <EOL> def test_different_type_freezer_property ( ) : <EOL> '''<STR_LIT>''' <EOL> class CustomFreezer ( Freezer ) : <EOL> def __init__ ( self , obj ) : <EOL> self . obj = obj <EOL> def freeze_handler ( self ) : <EOL> self . obj . different_type_freeze_counter += <NUM_LIT:1> <EOL> def thaw_handler ( self ) : <EOL> self . obj . different_type_thaw_counter += <NUM_LIT:1> <EOL> class E ( object ) : <EOL> different_type_freeze_counter = caching . CachedProperty ( <NUM_LIT:0> ) <EOL> different_type_thaw_counter = caching . CachedProperty ( <NUM_LIT:0> ) <EOL> different_type_freezer = FreezerProperty ( <EOL> freezer_type = CustomFreezer , <EOL> doc = '<STR_LIT>' <EOL> ) <EOL> e = E ( ) <EOL> assert E . different_type_freezer . __doc__ == '<STR_LIT>' <EOL> assert e . different_type_freezer . frozen == <NUM_LIT:0> <EOL> assert e . different_type_freeze_counter == <NUM_LIT:0> <EOL> assert e . different_type_thaw_counter == <NUM_LIT:0> <EOL> with e . different_type_freezer : <EOL> assert e . different_type_freezer . frozen == <NUM_LIT:1> <EOL> assert e . different_type_freeze_counter == <NUM_LIT:1> <EOL> assert e . different_type_thaw_counter == <NUM_LIT:0> <EOL> with e . different_type_freezer : <EOL> assert e . different_type_freezer . frozen == <NUM_LIT:2> <EOL> assert e . different_type_freeze_counter == <NUM_LIT:1> <EOL> assert e . different_type_thaw_counter == <NUM_LIT:0> <EOL> assert e . different_type_freezer . frozen == <NUM_LIT:1> <EOL> assert e . different_type_freeze_counter == <NUM_LIT:1> <EOL> assert e . different_type_thaw_counter == <NUM_LIT:0> <EOL> assert e . different_type_freezer . frozen == <NUM_LIT:0> <EOL> assert e . different_type_freeze_counter == <NUM_LIT:1> <EOL> assert e . different_type_thaw_counter == <NUM_LIT:1> <EOL> with e . different_type_freezer : <EOL> assert e . different_type_freezer . frozen == <NUM_LIT:1> <EOL> assert e . different_type_freeze_counter == <NUM_LIT:2> <EOL> assert e . different_type_thaw_counter == <NUM_LIT:1> <EOL> assert e . different_type_freezer . frozen == <NUM_LIT:0> <EOL> assert e . different_type_freeze_counter == <NUM_LIT:2> <EOL> assert e . different_type_thaw_counter == <NUM_LIT:2> </s>
