You've already forked httpie-cli
mirror of
https://github.com/httpie/cli.git
synced 2025-08-10 22:42:05 +02:00
Removed the "implicit_content_type" config option
If you used: "implicit_content_type": "form" You can achieve the the same result with: "default_options": ["--form"] If you used: "implicit_content_type": "json" Then it's the default behaviour and it can be removed. In either case HTTPie will migrate your config file on the next invocation.
This commit is contained in:
33
tests/test_config.py
Normal file
33
tests/test_config.py
Normal file
@@ -0,0 +1,33 @@
|
||||
from utils import TestEnvironment, http
|
||||
|
||||
|
||||
def test_default_options(httpbin):
|
||||
env = TestEnvironment()
|
||||
env.config['default_options'] = ['--form']
|
||||
env.config.save()
|
||||
r = http(httpbin.url + '/post', 'foo=bar', env=env)
|
||||
assert r.json['form'] == {"foo": "bar"}
|
||||
|
||||
|
||||
def test_default_options_overwrite(httpbin):
|
||||
env = TestEnvironment()
|
||||
env.config['default_options'] = ['--form']
|
||||
env.config.save()
|
||||
r = http('--json', httpbin.url + '/post', 'foo=bar', env=env)
|
||||
assert r.json['json'] == {"foo": "bar"}
|
||||
|
||||
|
||||
def test_migrate_implicit_content_type():
|
||||
config = TestEnvironment().config
|
||||
|
||||
config['implicit_content_type'] = 'json'
|
||||
config.save()
|
||||
config.load()
|
||||
assert 'implicit_content_type' not in config
|
||||
assert not config['default_options']
|
||||
|
||||
config['implicit_content_type'] = 'form'
|
||||
config.save()
|
||||
config.load()
|
||||
assert 'implicit_content_type' not in config
|
||||
assert config['default_options'] == ['--form']
|
@@ -189,13 +189,14 @@ def http(*args, **kwargs):
|
||||
stderr = env.stderr
|
||||
|
||||
args = list(args)
|
||||
extra_args = []
|
||||
if '--debug' not in args:
|
||||
if '--traceback' not in args:
|
||||
extra_args.append('--traceback')
|
||||
if not any('--timeout' in arg for arg in args):
|
||||
extra_args.append('--timeout=3')
|
||||
args = extra_args + args
|
||||
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:
|
||||
add_to_args.append('--traceback')
|
||||
if not any('--timeout' in arg for arg in args_with_config_defaults):
|
||||
add_to_args.append('--timeout=3')
|
||||
args = add_to_args + args
|
||||
|
||||
def dump_stderr():
|
||||
stderr.seek(0)
|
||||
|
Reference in New Issue
Block a user