#NEWLINE# @ mock . patch . object ( requests , 'get' , autospec = True ) #NEWLINE# def test_download_fail_connerror( self , req_get_mock ) : #NEWLINE# #INDENT# req_get_mock . side_effect = iter ( [ requests . ConnectionError ( ) ] ) #NEWLINE# file_mock = mock . Mock ( spec = file ) #NEWLINE# self . assertRaises ( exception . ImageDownloadFailed , req_get_mock . service . download , self . href , file_mock )