#NEWLINE# def test_over_release( self ) : #NEWLINE# #INDENT# x = LaxBoundedSemaphore ( 2 ) #NEWLINE# calls = [ ] #NEWLINE# for i in range ( 1 , 21 ) : #NEWLINE# #INDENT# x . acquire ( calls . append , i ) #NEWLINE# #UNINDENT# x . release ( ) #NEWLINE# x . acquire ( calls . append , 'x' ) #NEWLINE# x . release ( ) #NEWLINE# x . acquire ( calls . append , 'y' ) #NEWLINE# self . assertEqual ( calls , [ 1 , 2 , 3 , 4 ] ) #NEWLINE# for i in range ( 30 ) : #NEWLINE# #INDENT# x . release ( ) #NEWLINE# #UNINDENT# self . assertEqual ( calls , ( list ( range ( 1 , 21 ) ) + [ 'x' , 'y' ] ) ) #NEWLINE# self . assertEqual ( x . value , x . initial_value ) #NEWLINE# calls [ : ] = [ ] #NEWLINE# for i in range ( 1 , 11 ) : #NEWLINE# #INDENT# x . acquire ( calls . append , calls ) #NEWLINE# #UNINDENT# for i in range ( 1 , 11 ) : #NEWLINE# #INDENT# x . release ( ) #NEWLINE# #UNINDENT# self . assertEqual ( calls , list ( range ( 1 , 11 ) ) ) #NEWLINE# calls [ : ] = [ ] #NEWLINE# self . assertEqual ( x . value , x . initial_value ) #NEWLINE# x . acquire ( calls . append , 'x' ) #NEWLINE# self . assertEqual ( x . value , 1 ) #NEWLINE# x . acquire ( calls . append , 'y' ) #NEWLINE# self . assertEqual ( x . value , 0 ) #NEWLINE# x . release ( ) #NEWLINE# self . assertEqual ( x . value , 1 ) #NEWLINE# x . release ( ) #NEWLINE# self . assertEqual ( x . value , 2 ) #NEWLINE# x . release ( ) #NEWLINE# self . assertEqual ( x . value , 2 )