#NEWLINE# def test_useful_reraise_in_flush_endpoint( self ) : #NEWLINE# #INDENT# error_mock = Mock ( ) #NEWLINE# error_mock . read . return_value = six . b ( '{"status": 0, "error": "arbitrary error"}' ) #NEWLINE# broken_json = '{broken JSON' #NEWLINE# with patch ( 'six.moves.urllib.request.urlopen' , return_value = error_mock ) : #NEWLINE# #INDENT# self . consumer . send ( 'events' , broken_json ) #NEWLINE# with pytest . raises ( mixpanel . MixpanelException ) as excinfo : #NEWLINE# #INDENT# self . consumer . flush ( ) #NEWLINE# #UNINDENT# assert ( excinfo . value . message == ( '[%s]' % broken_json ) ) #NEWLINE# assert ( excinfo . value . endpoint == 'events' )