#NEWLINE# def test_w_exceptions_lt_max_retries( self ) : #NEWLINE# #INDENT# from gcloud.streaming.exceptions import RetryAfterError #NEWLINE# ( HTTP , RESPONSE ) = ( object ( ) , object ( ) ) #NEWLINE# REQUEST = _Request ( ) #NEWLINE# WAIT = ( 10 , ) #NEWLINE# ( _created , _checked ) = ( [ ] , [ ] ) #NEWLINE# _counter = ( [ None ] * 4 ) #NEWLINE# def _wo_exception( * args , **kw ) : #NEWLINE# #INDENT# _created . append ( ( args , kw ) ) #NEWLINE# if _counter : #NEWLINE# #INDENT# _counter . pop ( ) #NEWLINE# raise RetryAfterError ( RESPONSE , '' , REQUEST . url , 0.1 ) #NEWLINE# #UNINDENT# return RESPONSE #NEWLINE# #UNINDENT# response = self . _callFUT ( HTTP , attempt , retries = 5 , max_retry_wait = WAIT , wo_retry_func = _wo_exception , check_response_func = _checked . append ) #NEWLINE# self . assertTrue ( ( response is RESPONSE ) ) #NEWLINE# self . assertEqual ( len ( _created ) , 5 ) #NEWLINE# expected_kw = { #NEWLINE# #INDENT# 'redirections' : 5 , #NEWLINE# 'check_response_func' : _checked . append , #NEWLINE# #UNINDENT# } #NEWLINE# for attempt in _created : #NEWLINE# #INDENT# self . assertEqual ( attempt , ( ( HTTP , REQUEST ) , expected_kw ) ) #NEWLINE# #UNINDENT# self . assertEqual ( _checked , [ ] )