-
Notifications
You must be signed in to change notification settings - Fork 4k
feat: add default_timeout support to config #1832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,3 +102,36 @@ def test_custom_config_dir(monkeypatch: MonkeyPatch, tmp_path: Path): | |
| def test_windows_config_dir(monkeypatch: MonkeyPatch): | ||
| monkeypatch.delenv(ENV_HTTPIE_CONFIG_DIR, raising=False) | ||
| assert get_default_config_dir() == DEFAULT_WINDOWS_CONFIG_DIR | ||
|
|
||
|
|
||
| def test_default_headers(httpbin): | ||
| env = MockEnvironment() | ||
| env.config['default_headers'] = {'X-Custom-Header': 'test-value'} | ||
| env.config.save() | ||
| r = http(httpbin + '/headers', env=env) | ||
| assert HTTP_OK in r | ||
| assert r.json['headers']['X-Custom-Header'] == 'test-value' | ||
|
|
||
|
|
||
| def test_default_headers_overridable(httpbin): | ||
| env = MockEnvironment() | ||
| env.config['default_headers'] = {'X-Custom-Header': 'default-value'} | ||
| env.config.save() | ||
| r = http(httpbin + '/headers', 'X-Custom-Header:override-value', env=env) | ||
| assert HTTP_OK in r | ||
| assert r.json['headers']['X-Custom-Header'] == 'override-value' | ||
|
|
||
|
|
||
| def test_default_timeout(httpbin): | ||
| env = MockEnvironment() | ||
| env.config['default_timeout'] = 30 | ||
| env.config.save() | ||
| assert env.config.default_timeout == 30 | ||
|
|
||
|
|
||
| def test_default_timeout_overridable(httpbin): | ||
| env = MockEnvironment() | ||
| env.config['default_timeout'] = 30 | ||
| env.config.save() | ||
| r = http('--timeout=60', httpbin + '/get', env=env) | ||
| assert HTTP_OK in r | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: add a specific assertion to verify the timeout override value While checking for Adding an assertion for checking would make this test block significantly stronger. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: safely guard the
envreference to prevent NoneType attribute errorsWhile
envis safely guarded up inmake_send_kwargs, it is missing a guard here inmake_request_kwargson line 350: