#NEWLINE# def test_lfu( ) : #NEWLINE# #INDENT# cache = Cache ( ) #NEWLINE# cache [ 'a' ] = 'x' #NEWLINE# assert ( len ( cache ) == 1 ) #NEWLINE# assert ( len ( cache . queue ) == 1 ) #NEWLINE# _ = cache [ 'a' ] #NEWLINE# assert ( len ( cache ) == 1 ) #NEWLINE# assert ( len ( cache . queue ) == 2 ) #NEWLINE# assert ( cache . cache [ 'a' ] == ( 2 , 'x' ) ) #NEWLINE# _ = cache [ 'a' ] #NEWLINE# assert ( len ( cache ) == 1 ) #NEWLINE# assert ( len ( cache . queue ) == 3 ) #NEWLINE# assert ( cache . cache [ 'a' ] == ( 3 , 'x' ) ) #NEWLINE# cache . evict_one ( ) #NEWLINE# assert ( len ( cache ) == 1 ) #NEWLINE# assert ( len ( cache . queue ) == 2 ) #NEWLINE# assert ( cache . cache [ 'a' ] == ( 2 , 'x' ) ) #NEWLINE# cache . evict_one ( ) #NEWLINE# assert ( len ( cache ) == 1 ) #NEWLINE# assert ( len ( cache . queue ) == 1 ) #NEWLINE# assert ( cache . cache [ 'a' ] == ( 1 , 'x' ) ) #NEWLINE# cache . evict_one ( ) #NEWLINE# assert ( len ( cache ) == 0 ) #NEWLINE# assert ( len ( cache . queue ) == 0 ) #NEWLINE# cache [ 'a' ] = 'x' #NEWLINE# assert ( len ( cache ) == 1 ) #NEWLINE# assert ( len ( cache . queue ) == 1 ) #NEWLINE# cache [ 'a' ] = 'y' #NEWLINE# assert ( len ( cache ) == 1 ) #NEWLINE# assert ( len ( cache . queue ) == 2 ) #NEWLINE# assert ( cache . cache [ 'a' ] == ( 2 , 'y' ) )