#NEWLINE# def test_shell_exceptions( self ) : #NEWLINE# #INDENT# fake_tmp_file = flexmock ( name = 'tempfile' ) #NEWLINE# fake_tmp_file . should_receive ( 'write' ) . and_return ( ) #NEWLINE# fake_tmp_file . should_receive ( 'read' ) . and_return ( '' ) #NEWLINE# fake_tmp_file . should_receive ( 'seek' ) . and_return ( ) #NEWLINE# fake_tmp_file . should_receive ( 'close' ) . and_return ( ) #NEWLINE# flexmock ( tempfile ) . should_receive ( 'NamedTemporaryFile' ) . and_return ( fake_tmp_file ) #NEWLINE# flexmock ( tempfile ) . should_receive ( 'TemporaryFile' ) . and_return ( fake_tmp_file ) #NEWLINE# fake_result = flexmock ( name = 'result' ) #NEWLINE# fake_result . returncode = 1 #NEWLINE# fake_result . should_receive ( 'wait' ) . and_return ( ) #NEWLINE# fake_subprocess = flexmock ( subprocess ) #NEWLINE# fake_subprocess . should_receive ( 'Popen' ) . and_return ( fake_result ) #NEWLINE# fake_subprocess . STDOUT = '' #NEWLINE# flexmock ( time ) . should_receive ( 'sleep' ) . and_return ( ) #NEWLINE# self . assertRaises ( ShellException , LocalState . shell , 'fake_cmd' , False ) #NEWLINE# self . assertRaises ( ShellException , LocalState . shell , 'fake_cmd' , False , stdin = 'fake_stdin' ) #NEWLINE# fake_subprocess . should_receive ( 'Popen' ) . and_raise ( OSError ) #NEWLINE# self . assertRaises ( ShellException , LocalState . shell , 'fake_cmd' , False ) #NEWLINE# self . assertRaises ( ShellException , LocalState . shell , 'fake_cmd' , False , stdin = 'fake_stdin' )