def run(test_state, *command, **kwargs): """ Sends the given command list to the command line client. :returns: The STDOUT output of the command. """ old_stdout = sys.stdout capturedSTDOUT = StringIO() syn_client = kwargs.get('syn', test_state.syn) stream_handler = logging.StreamHandler(capturedSTDOUT) try: sys.stdout = capturedSTDOUT syn_client.logger.addHandler(stream_handler) sys.argv = [item for item in command] args = test_state.parser.parse_args() args.debug = True cmdline.perform_main(args, syn_client) except SystemExit: pass # Prevent the test from quitting prematurely finally: sys.stdout = old_stdout syn_client.logger.handlers.remove(stream_handler) capturedSTDOUT = capturedSTDOUT.getvalue() return capturedSTDOUT
def run(*command, **kwargs): """ Sends the given command list to the command line client. :returns: The STDOUT output of the command. """ old_stdout = sys.stdout capturedSTDOUT = StringIO() syn_client = kwargs.get('syn', syn) stream_handler = logging.StreamHandler(capturedSTDOUT) try: sys.stdout = capturedSTDOUT syn_client.logger.addHandler(stream_handler) sys.argv = [item for item in command] args = parser.parse_args() args.debug = True cmdline.perform_main(args, syn_client) except SystemExit: pass # Prevent the test from quitting prematurely finally: sys.stdout = old_stdout syn_client.logger.handlers.remove(stream_handler) capturedSTDOUT = capturedSTDOUT.getvalue() return capturedSTDOUT
def run(*command): """ Sends the given command list to the command line client. :returns: The STDOUT output of the command. """ print ' '.join(command) old_stdout = sys.stdout capturedSTDOUT = StringIO() try: sys.stdout = capturedSTDOUT sys.argv = [item for item in command] args = parser.parse_args() cmdline.perform_main(args, syn) except SystemExit: pass # Prevent the test from quitting prematurely finally: sys.stdout = old_stdout capturedSTDOUT = capturedSTDOUT.getvalue() print capturedSTDOUT return capturedSTDOUT