#NEWLINE# def test_generate_crash_log( self ) : #NEWLINE# #INDENT# crashlog_suffix = '123456' #NEWLINE# flexmock ( uuid ) #NEWLINE# uuid . should_receive ( 'uuid4' ) . and_return ( crashlog_suffix ) #NEWLINE# exception_class = 'Exception' #NEWLINE# exception_message = 'baz message' #NEWLINE# exception = Exception ( exception_message ) #NEWLINE# stacktrace = '\n' . join ( [ 'Traceback (most recent call last):' , '  File "<stdin>", line 2, in <module>' , '{0}: {1}' . format ( exception_class , exception_message ) ] ) #NEWLINE# flexmock ( platform ) #NEWLINE# platform . should_receive ( 'platform' ) . and_return ( 'MyOS' ) #NEWLINE# platform . should_receive ( 'python_implementation' ) . and_return ( 'MyPython' ) #NEWLINE# flexmock ( locale ) #NEWLINE# locale . should_receive ( 'getlocale' ) . and_return ( ( "'Murica" , None ) ) #NEWLINE# expected = '{0}log-{1}' . format ( LocalState . LOCAL_APPSCALE_PATH , crashlog_suffix ) #NEWLINE# fake_file = flexmock ( name = 'fake_file' ) #NEWLINE# fake_file . should_receive ( 'write' ) . with_args ( str ) #NEWLINE# fake_builtins = flexmock ( sys . modules [ '__builtin__' ] ) #NEWLINE# fake_builtins . should_call ( 'open' ) #NEWLINE# fake_builtins . should_receive ( 'open' ) . with_args ( expected , 'w' ) . and_return ( fake_file ) #NEWLINE# flexmock ( AppScaleLogger ) #NEWLINE# AppScaleLogger . should_receive ( 'warn' ) #NEWLINE# actual = LocalState . generate_crash_log ( exception , stacktrace ) #NEWLINE# self . assertEquals ( expected , actual )