#NEWLINE# def test_from_exceptions_populates_a_queue( self ) : #NEWLINE# #INDENT# 'Ensure a Queue is properly populated from exceptions.' #NEWLINE# urls = [ 'https://httpbin.org/get?n={0}' . format ( n ) for n in range ( 5 ) ] #NEWLINE# Exc = pool . ThreadException #NEWLINE# excs = ( Exc ( { #NEWLINE# #INDENT# 'method' : 'GET' , #NEWLINE# 'url' : url , #NEWLINE# #UNINDENT# } , None ) for url in urls ) #NEWLINE# job_queue = mock . MagicMock ( ) #NEWLINE# with mock . patch . object ( queue , 'Queue' , return_value = job_queue ) : #NEWLINE# #INDENT# with mock . patch . object ( thread , 'SessionThread' ) : #NEWLINE# #INDENT# pool . Pool . from_exceptions ( excs ) #NEWLINE# #UNINDENT# #UNINDENT# assert ( job_queue . put . call_count == 5 ) #NEWLINE# assert ( job_queue . put . mock_calls == [ mock . call ( { #NEWLINE# #INDENT# 'method' : 'GET' , #NEWLINE# 'url' : url , #NEWLINE# #UNINDENT# } ) for url in urls ] )