You've already forked httpie-cli
mirror of
https://github.com/httpie/cli.git
synced 2025-08-10 22:42:05 +02:00
Exit with status 130 on CTRL-C
http://www.tldp.org/LDP/abs/html/exitcodes.html #531
This commit is contained in:
@@ -1,9 +1,25 @@
|
||||
import mock
|
||||
|
||||
from httpie import ExitStatus
|
||||
from utils import TestEnvironment, http, HTTP_OK
|
||||
|
||||
|
||||
def test_keyboard_interrupt_during_arg_parsing_exit_status(httpbin):
|
||||
with mock.patch('httpie.cli.parser.parse_args',
|
||||
side_effect=KeyboardInterrupt()):
|
||||
r = http('GET', httpbin.url + '/status/200', error_exit_ok=True)
|
||||
assert r.exit_status == ExitStatus.ERROR_CTRL_C
|
||||
|
||||
|
||||
def test_keyboard_interrupt_in_program_exit_status(httpbin):
|
||||
with mock.patch('httpie.core.program',
|
||||
side_effect=KeyboardInterrupt()):
|
||||
r = http('GET', httpbin.url + '/status/200', error_exit_ok=True)
|
||||
assert r.exit_status == ExitStatus.ERROR_CTRL_C
|
||||
|
||||
|
||||
def test_ok_response_exits_0(httpbin):
|
||||
r = http('GET', httpbin.url + '/status/200')
|
||||
r = http('GET', httpbin.url + '/get')
|
||||
assert HTTP_OK in r
|
||||
assert r.exit_status == ExitStatus.OK
|
||||
|
||||
|
@@ -192,7 +192,7 @@ def http(*args, **kwargs):
|
||||
args_with_config_defaults = args + env.config.default_options
|
||||
add_to_args = []
|
||||
if '--debug' not in args_with_config_defaults:
|
||||
if '--traceback' not in args_with_config_defaults:
|
||||
if not error_exit_ok and '--traceback' not in args_with_config_defaults:
|
||||
add_to_args.append('--traceback')
|
||||
if not any('--timeout' in arg for arg in args_with_config_defaults):
|
||||
add_to_args.append('--timeout=3')
|
||||
|
Reference in New Issue
Block a user