<s> from nosyd . nosyd import * <EOL> from nosyd . cache import * <EOL> class CountCalls : <EOL> def __init__ ( self ) : <EOL> self . my_cache = { } <EOL> self . calls = <NUM_LIT:0> <EOL> @ MWT ( timeout = <NUM_LIT> , cache_attr_name = "<STR_LIT>" ) <EOL> def cachedCall ( self ) : <EOL> self . calls += <NUM_LIT:1> <EOL> class TestNosyd : <EOL> def test_cache ( self ) : <EOL> cc = CountCalls ( ) <EOL> assert cc . calls == <NUM_LIT:0> <EOL> assert len ( cc . my_cache ) == <NUM_LIT:0> <EOL> cc . cachedCall ( ) <EOL> assert cc . calls == <NUM_LIT:1> <EOL> assert len ( cc . my_cache ) == <NUM_LIT:1> <EOL> cc . cachedCall ( ) <EOL> assert cc . calls == <NUM_LIT:1> <EOL> assert len ( cc . my_cache ) == <NUM_LIT:1> <EOL> cc . my_cache . clear ( ) <EOL> assert len ( cc . my_cache ) == <NUM_LIT:0> <EOL> cc . cachedCall ( ) <EOL> assert cc . calls == <NUM_LIT:2> <EOL> assert len ( cc . my_cache ) == <NUM_LIT:1> <EOL> time . sleep ( <NUM_LIT:0.5> ) <EOL> MWT ( ) . collect ( ) <EOL> assert len ( cc . my_cache ) == <NUM_LIT:0> <EOL> cc . cachedCall ( ) <EOL> assert cc . calls == <NUM_LIT:3> <EOL> assert len ( cc . my_cache ) == <NUM_LIT:1> </s>
