<s> from cloudferry . lib . utils . cache import Memoized , Cached <EOL> from tests import test <EOL> class MemoizationTestCase ( test . TestCase ) : <EOL> def test_treats_self_as_separate_objects ( self ) : <EOL> class C ( object ) : <EOL> def __init__ ( self , i ) : <EOL> self . i = i <EOL> @ Memoized <EOL> def get_i ( self ) : <EOL> return self . i <EOL> o1 = C ( <NUM_LIT:1> ) <EOL> o2 = C ( <NUM_LIT:2> ) <EOL> self . assertNotEqual ( o1 . get_i ( ) , o2 . get_i ( ) ) <EOL> self . assertEqual ( o1 . get_i ( ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( o2 . get_i ( ) , <NUM_LIT:2> ) <EOL> def test_takes_value_from_cache ( self ) : <EOL> class C ( object ) : <EOL> def __init__ ( self , i ) : <EOL> self . i = i <EOL> @ Memoized <EOL> def get_i ( self ) : <EOL> return self . i <EOL> def set_i ( self , i ) : <EOL> self . i = i <EOL> original = <NUM_LIT:1> <EOL> o = C ( original ) <EOL> self . assertEqual ( o . get_i ( ) , original ) <EOL> o . set_i ( <NUM_LIT:10> ) <EOL> self . assertEqual ( o . get_i ( ) , original ) <EOL> class CacheTestCase ( test . TestCase ) : <EOL> def test_resets_cache_when_modifier_called ( self ) : <EOL> @ Cached ( getter = '<STR_LIT>' , modifier = '<STR_LIT>' ) <EOL> class C ( object ) : <EOL> def __init__ ( self , i ) : <EOL> self . i = i <EOL> def get_i ( self ) : <EOL> return self . i <EOL> def set_i ( self , i ) : <EOL> self . i = i <EOL> o = C ( <NUM_LIT:1> ) <EOL> self . assertEqual ( o . get_i ( ) , <NUM_LIT:1> ) <EOL> o . set_i ( <NUM_LIT:100> ) <EOL> self . assertEqual ( o . get_i ( ) , <NUM_LIT:100> ) </s>
