#NEWLINE# def test_put_failure( ) : #NEWLINE# #INDENT# td = api . API ( 'APIKEY' ) #NEWLINE# with mock . patch ( 'time.sleep' ) as t_sleep : #NEWLINE# #INDENT# td . http . urlopen = mock . MagicMock ( ) #NEWLINE# td . http . urlopen . return_value = make_raw_response ( 500 , b'error' ) #NEWLINE# with pytest . raises ( api . APIError ) as error : #NEWLINE# #INDENT# with td . put ( '/foo' , b'body' , 7 ) as response : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# assert t_sleep . called #NEWLINE# sleeps = [ args [ 0 ] for ( args , kwargs ) in t_sleep . call_args_list ] #NEWLINE# assert ( td . _max_cumul_retry_delay < sum ( sleeps ) )