#NEWLINE# def test_helpers_ratelimit( worker ) : #NEWLINE# #INDENT# worker . start_deps ( ) #NEWLINE# assert ( ratelimit ( 'k3' , 1 , per = 1 ) == 1 ) #NEWLINE# assert ( ratelimit ( 'k3' , 1 , per = 1 ) == 0 ) #NEWLINE# assert ( ratelimit ( 'k3' , 1 , per = 1 ) == 0 ) #NEWLINE# for i in range ( 0 , 10 ) : #NEWLINE# #INDENT# r = ratelimit ( 'k' , 10 , per = 1 ) #NEWLINE# assert ( worker == ( 10 - i ) ) #NEWLINE# #UNINDENT# assert ( ratelimit ( 'k' , 10 , per = 1 ) == 0 ) #NEWLINE# assert ( ratelimit ( 'k2' , 5 , per = 1 ) == 5 ) #NEWLINE# for i in range ( 0 , 100 ) : #NEWLINE# #INDENT# assert ( ratelimit ( 'k' , 10 , per = 1 ) == 0 ) #NEWLINE# #UNINDENT# time . sleep ( 1 ) #NEWLINE# assert ( ratelimit ( 'k' , 10 , per = 1 ) == 10 ) #NEWLINE# assert ( ratelimit ( 'k' , 10 , per = 1 ) == 9 ) #NEWLINE# assert ( ratelimit ( 'k' , 10 , per = 10 ) == 10 ) #NEWLINE# assert ( ratelimit ( 'k' , 10 , per = 10 ) == 9 ) #NEWLINE# worker . stop_deps ( )