<s> from __future__ import print_function <EOL> import unittest <EOL> import threading <EOL> import inspect <EOL> import wrapt <EOL> @ wrapt . decorator <EOL> def memoize ( wrapped , instance , args , kwargs ) : <EOL> if instance is None and inspect . isclass ( wrapped ) : <EOL> return wrapped ( * args , ** kwargs ) <EOL> cache = wrapped . __dict__ . setdefault ( '<STR_LIT>' , { } ) <EOL> try : <EOL> key = ( args , frozenset ( kwargs . items ( ) ) ) <EOL> return cache [ key ] <EOL> except KeyError : <EOL> result = cache [ key ] = wrapped ( * args , ** kwargs ) <EOL> return result <EOL> @ memoize <EOL> def function1 ( count , text ) : <EOL> return count * text <EOL> class C1 ( object ) : <EOL> @ memoize <EOL> def function1 ( self , count , text ) : <EOL> return count * text <EOL> @ memoize <EOL> @ classmethod <EOL> def function2 ( cls , count , text ) : <EOL> return count * text <EOL> @ memoize <EOL> @ staticmethod <EOL> def function3 ( count , text ) : <EOL> return count * text <EOL> c1 = C1 ( ) <EOL> class TestSynchronized ( unittest . TestCase ) : <EOL> def test_function ( self ) : <EOL> value1 = function1 ( <NUM_LIT:10> , '<STR_LIT>' ) <EOL> value2 = function1 ( <NUM_LIT:10> , '<STR_LIT>' ) <EOL> self . assertEqual ( value1 , value2 ) <EOL> self . assertEqual ( id ( value1 ) , id ( value2 ) ) <EOL> self . assertTrue ( hasattr ( function1 , '<STR_LIT>' ) ) <EOL> def test_instancemethod ( self ) : <EOL> value1 = c1 . function1 ( <NUM_LIT:10> , '<STR_LIT>' ) <EOL> value2 = c1 . function1 ( <NUM_LIT:10> , '<STR_LIT>' ) <EOL> self . assertEqual ( value1 , value2 ) <EOL> self . assertEqual ( id ( value1 ) , id ( value2 ) ) <EOL> self . assertTrue ( hasattr ( C1 . function1 , '<STR_LIT>' ) ) <EOL> def test_classmethod ( self ) : <EOL> value1 = C1 . function2 ( <NUM_LIT:10> , '<STR_LIT>' ) <EOL> value2 = C1 . function2 ( <NUM_LIT:10> , '<STR_LIT>' ) <EOL> self . assertEqual ( value1 , value2 ) <EOL> self . assertEqual ( id ( value1 ) , id ( value2 ) ) <EOL> self . assertTrue ( hasattr ( C1 . function2 , '<STR_LIT>' ) ) <EOL> def test_staticmethod ( self ) : <EOL> value1 = C1 . function3 ( <NUM_LIT:10> , '<STR_LIT>' ) <EOL> value2 = C1 . function3 ( <NUM_LIT:10> , '<STR_LIT>' ) <EOL> self . assertEqual ( value1 , value2 ) <EOL> self . assertEqual ( id ( value1 ) , id ( value2 ) ) <EOL> self . assertTrue ( hasattr ( C1 . function3 , '<STR_LIT>' ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
