def run_and_exit(cli_args=None, prompt_commands=None):
 if (cli_args is None):
  cli_args = []
 if (prompt_commands is None):
  prompt_commands = ['exit']
 else:
  prompt_commands += ['exit']
 orig_argv = sys.argv
 sys.argv = (['http-prompt'] + cli_args)
 try:
  with patch.multiple('http_prompt.cli', prompt=DEFAULT, execute=DEFAULT) as mocks:
   mocks['execute'].side_effect = execute
   mocks['prompt'].side_effect = prompt_commands
   result = CliRunner().invoke(cli, cli_args)
   context = mocks['execute'].call_args[0][1]
  return (result, context)
 finally:
  sys.argv = orig_argv

def run_and_exit ( cli_args = None , prompt_commands = None ) : if ( cli_args is None ) : cli_args = [ ] if ( prompt_commands is None ) : prompt_commands = [ 'exit' ] else : prompt_commands += [ 'exit' ] orig_argv = sys . argv sys . argv = ( [ 'http-prompt' ] + cli_args ) try : with patch . multiple ( 'http_prompt.cli' , prompt = DEFAULT , execute = DEFAULT ) as mocks : mocks [ 'execute' ] . side_effect = execute mocks [ 'prompt' ] . side_effect = prompt_commands result = CliRunner ( ) . invoke ( cli , cli_args ) context = mocks [ 'execute' ] . call_args [ 0 ] [ 1 ] return ( result , context ) finally : sys . argv = orig_argv
run http-prompt executable .