#NEWLINE# def run_srb( self , * argv , **kwargs ) : #NEWLINE# #INDENT# if ( ( len ( argv ) == 1 ) and isinstance ( mock_stdout [ 0 ] , six . string_types ) ) : #NEWLINE# #INDENT# argv = shlex . split ( argv [ 0 ] ) #NEWLINE# #UNINDENT# mock_stdout = six . StringIO ( ) #NEWLINE# mock_stderr = six . StringIO ( ) #NEWLINE# if ( 'exp_results' in kwargs ) : #NEWLINE# #INDENT# exp_results = kwargs [ 'exp_results' ] #NEWLINE# argv = argv [ : ( - 1 ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# exp_results = None #NEWLINE# #UNINDENT# srb_args = ( [ '' , self . tempfile ] + [ str ( s ) for s in argv ] ) #NEWLINE# try : #NEWLINE# #INDENT# with mock . patch ( 'sys.stdout' , mock_stdout ) : #NEWLINE# #INDENT# with mock . patch ( 'sys.stderr' , mock_stderr ) : #NEWLINE# #INDENT# ringbuilder . main ( srb_args ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except SystemExit as err : #NEWLINE# #INDENT# valid_exit_codes = None #NEWLINE# if ( ( exp_results is not None ) and ( 'valid_exit_codes' in exp_results ) ) : #NEWLINE# #INDENT# valid_exit_codes = exp_results [ 'valid_exit_codes' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# valid_exit_codes = ( 0 , 1 ) #NEWLINE# #UNINDENT# if ( err . code not in valid_exit_codes ) : #NEWLINE# #INDENT# msg = ( 'Unexpected exit status %s\n' % err . code ) #NEWLINE# msg += ( 'STDOUT:\n%s\nSTDERR:\n%s\n' % ( mock_stdout . getvalue ( ) , mock_stderr . getvalue ( ) ) ) #NEWLINE# self . fail ( msg ) #NEWLINE# #UNINDENT# #UNINDENT# return ( mock_stdout . getvalue ( ) , mock_stderr . getvalue ( ) )