#NEWLINE# @ patch ( 'prestoadmin.util.application.sys.stderr' ) #NEWLINE# def test_handles_errors( self , stderr_mock , logging_mock , filesystem_mock ) : #NEWLINE# #INDENT# def should_fail( ) : #NEWLINE# #INDENT# with Application ( APPLICATION_NAME ) : #NEWLINE# #INDENT# raise Exception ( 'User facing error message' ) #NEWLINE# #UNINDENT# #UNINDENT# self . assertRaises ( SystemExit , stderr_mock ) #NEWLINE# stderr_mock . write . assert_has_calls ( [ call ( 'User facing error message' ) , call ( '\n' ) ] )