summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Roztocil <jakub@roztocil.co>2024-03-04 18:12:18 +0100
committerJakub Roztocil <jakub@roztocil.co>2024-03-04 18:12:18 +0100
commit3de7c82077ab773ca957c851e94c4b375721feb6 (patch)
treed89c879f675460ef8245f7a46ff2e4407bf64c8b
parentdb16bbee961ceb93b7831fe1ec44a72d56a33e38 (diff)
Cleanup
-rw-r--r--tests/conftest.py9
-rw-r--r--tests/test_auth.py2
-rw-r--r--tests/test_binary.py6
-rw-r--r--tests/test_cli.py20
-rw-r--r--tests/test_compress.py4
-rw-r--r--tests/test_config.py4
-rw-r--r--tests/test_cookie_on_redirects.py2
-rw-r--r--tests/test_defaults.py34
-rw-r--r--tests/test_downloads.py2
-rw-r--r--tests/test_encoding.py32
-rw-r--r--tests/test_exit_status.py18
-rw-r--r--tests/test_output.py38
-rw-r--r--tests/test_redirects.py20
-rw-r--r--tests/test_regressions.py4
-rw-r--r--tests/test_sessions.py50
-rw-r--r--tests/test_stream.py8
-rw-r--r--tests/test_uploads.py28
-rw-r--r--tests/test_windows.py4
-rw-r--r--tests/utils/__init__.py2
19 files changed, 140 insertions, 147 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index a42ccbb5..551a6367 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -75,15 +75,8 @@ def _remote_httpbin_available():
@pytest.fixture
def remote_httpbin(_remote_httpbin_available):
-
if _remote_httpbin_available:
- class Server(str):
- """Look like `pytest_httpbin.serve.Server` but only provide URL info."""
- @property
- def url(self):
- return self
-
- return Server('http://' + REMOTE_HTTPBIN_DOMAIN)
+ return 'http://' + REMOTE_HTTPBIN_DOMAIN
pytest.skip(f'{REMOTE_HTTPBIN_DOMAIN} not resolvable')
diff --git a/tests/test_auth.py b/tests/test_auth.py
index 696fb228..83423efe 100644
--- a/tests/test_auth.py
+++ b/tests/test_auth.py
@@ -42,7 +42,7 @@ def test_bearer_auth(httpbin_both, token):
new=lambda self, prompt: 'password')
def test_password_prompt(httpbin):
r = http('--auth', 'user',
- 'GET', httpbin.url + '/basic-auth/user/password')
+ 'GET', httpbin + '/basic-auth/user/password')
assert HTTP_OK in r
assert r.json == {'authenticated': True, 'user': 'user'}
diff --git a/tests/test_binary.py b/tests/test_binary.py
index ca51aa16..c5e63ec3 100644
--- a/tests/test_binary.py
+++ b/tests/test_binary.py
@@ -15,18 +15,18 @@ class TestBinaryRequestData:
stdin_isatty=False,
stdout_isatty=False
)
- r = http('--print=B', 'POST', httpbin.url + '/post', env=env)
+ r = http('--print=B', 'POST', httpbin + '/post', env=env)
assert r == BIN_FILE_CONTENT
def test_binary_file_path(self, httpbin):
env = MockEnvironment(stdin_isatty=True, stdout_isatty=False)
- r = http('--print=B', 'POST', httpbin.url + '/post',
+ r = http('--print=B', 'POST', httpbin + '/post',
'@' + BIN_FILE_PATH_ARG, env=env)
assert r == BIN_FILE_CONTENT
def test_binary_file_form(self, httpbin):
env = MockEnvironment(stdin_isatty=True, stdout_isatty=False)
- r = http('--print=B', '--form', 'POST', httpbin.url + '/post',
+ r = http('--print=B', '--form', 'POST', httpbin + '/post',
'test@' + BIN_FILE_PATH_ARG, env=env)
assert bytes(BIN_FILE_CONTENT) in bytes(r)
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 6504c8a9..2cd27574 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -151,17 +151,17 @@ class TestItemParsing:
class TestQuerystring:
def test_query_string_params_in_url(self, httpbin):
- r = http('--print=Hhb', 'GET', httpbin.url + '/get?a=1&b=2')
+ r = http('--print=Hhb', 'GET', httpbin + '/get?a=1&b=2')
path = '/get?a=1&b=2'
- url = httpbin.url + path
+ url = httpbin + path
assert HTTP_OK in r
assert f'GET {path} HTTP/1.1' in r
assert f'"url": "{url}"' in r
def test_query_string_params_items(self, httpbin):
- r = http('--print=Hhb', 'GET', httpbin.url + '/get', 'a==1')
+ r = http('--print=Hhb', 'GET', httpbin + '/get', 'a==1')
path = '/get?a=1'
- url = httpbin.url + path
+ url = httpbin + path
assert HTTP_OK in r
assert f'GET {path} HTTP/1.1' in r
assert f'"url": "{url}"' in r
@@ -169,9 +169,9 @@ class TestQuerystring:
def test_query_string_params_in_url_and_items_with_duplicates(self,
httpbin):
r = http('--print=Hhb', 'GET',
- httpbin.url + '/get?a=1&a=1', 'a==1', 'a==1')
+ httpbin + '/get?a=1&a=1', 'a==1', 'a==1')
path = '/get?a=1&a=1&a=1&a=1'
- url = httpbin.url + path
+ url = httpbin + path
assert HTTP_OK in r
assert f'GET {path} HTTP/1.1' in r
assert f'"url": "{url}"' in r
@@ -320,11 +320,11 @@ class TestArgumentParser:
class TestNoOptions:
def test_valid_no_options(self, httpbin):
- r = http('--verbose', '--no-verbose', 'GET', httpbin.url + '/get')
+ r = http('--verbose', '--no-verbose', 'GET', httpbin + '/get')
assert 'GET /get HTTP/1.1' not in r
def test_invalid_no_options(self, httpbin):
- r = http('--no-war', 'GET', httpbin.url + '/get',
+ r = http('--no-war', 'GET', httpbin + '/get',
tolerate_error_exit_status=True)
assert r.exit_status == ExitStatus.ERROR
assert 'unrecognized arguments: --no-war' in r.stderr
@@ -338,13 +338,13 @@ class TestStdin:
stdin=StdinBytesIO(FILE_PATH.read_bytes()),
stdin_isatty=False,
)
- r = http('--ignore-stdin', '--verbose', httpbin.url + '/get', env=env)
+ r = http('--ignore-stdin', '--verbose', httpbin + '/get', env=env)
assert HTTP_OK in r
assert 'GET /get HTTP' in r, "Don't default to POST."
assert FILE_CONTENT not in r, "Don't send stdin data."
def test_ignore_stdin_cannot_prompt_password(self, httpbin):
- r = http('--ignore-stdin', '--auth=no-password', httpbin.url + '/get',
+ r = http('--ignore-stdin', '--auth=no-password', httpbin + '/get',
tolerate_error_exit_status=True)
assert r.exit_status == ExitStatus.ERROR
assert 'because --ignore-stdin' in r.stderr
diff --git a/tests/test_compress.py b/tests/test_compress.py
index 854a23e2..de5d8a7c 100644
--- a/tests/test_compress.py
+++ b/tests/test_compress.py
@@ -29,14 +29,14 @@ def assert_decompressed_equal(base64_compressed_data, expected_str):
def test_cannot_combine_compress_with_chunked(httpbin):
- r = http('--compress', '--chunked', httpbin.url + '/get',
+ r = http('--compress', '--chunked', httpbin + '/get',
tolerate_error_exit_status=True)
assert r.exit_status == ExitStatus.ERROR
assert 'cannot combine --compress and --chunked' in r.stderr
def test_cannot_combine_compress_with_multipart(httpbin):
- r = http('--compress', '--multipart', httpbin.url + '/get',
+ r = http('--compress', '--multipart', httpbin + '/get',
tolerate_error_exit_status=True)
assert r.exit_status == ExitStatus.ERROR
assert 'cannot combine --compress and --multipart' in r.stderr
diff --git a/tests/test_config.py b/tests/test_config.py
index be19d572..1d2eea07 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -17,7 +17,7 @@ def test_default_options(httpbin):
env = MockEnvironment()
env.config['default_options'] = ['--form']
env.config.save()
- r = http(httpbin.url + '/post', 'foo=bar', env=env)
+ r = http(httpbin + '/post', 'foo=bar', env=env)
assert r.json['form'] == {
"foo": "bar"
}
@@ -51,7 +51,7 @@ def test_default_options_overwrite(httpbin):
env = MockEnvironment()
env.config['default_options'] = ['--form']
env.config.save()
- r = http('--json', httpbin.url + '/post', 'foo=bar', env=env)
+ r = http('--json', httpbin + '/post', 'foo=bar', env=env)
assert r.json['json'] == {
"foo": "bar"
}
diff --git a/tests/test_cookie_on_redirects.py b/tests/test_cookie_on_redirects.py
index c5842f5b..2b0ab73b 100644
--- a/tests/test_cookie_on_redirects.py
+++ b/tests/test_cookie_on_redirects.py
@@ -12,7 +12,7 @@ def test_explicit_user_set_cookie(httpbin, target_httpbin, request):
r = http(
'--follow',
httpbin + '/redirect-to',
- f'url=={target_httpbin.url}/cookies',
+ f'url=={target_httpbin}/cookies',
'Cookie:a=b'
)
assert r.json == {'cookies': {}}
diff --git a/tests/test_defaults.py b/tests/test_defaults.py
index 267be2ae..dc912116 100644
--- a/tests/test_defaults.py
+++ b/tests/test_defaults.py
@@ -16,7 +16,7 @@ def test_default_headers_case_insensitive(httpbin):
r = http(
'--debug',
'--print=H',
- httpbin.url + '/post',
+ httpbin + '/post',
'CONTENT-TYPE:application/json-patch+json',
'a=b',
)
@@ -27,26 +27,26 @@ def test_default_headers_case_insensitive(httpbin):
# noinspection PyPep8Naming
class TestImplicitHTTPMethod:
def test_implicit_GET(self, httpbin):
- r = http(httpbin.url + '/get')
+ r = http(httpbin + '/get')
assert HTTP_OK in r
def test_implicit_GET_with_headers(self, httpbin):
- r = http(httpbin.url + '/headers', 'Foo:bar')
+ r = http(httpbin + '/headers', 'Foo:bar')
assert HTTP_OK in r
assert r.json['headers']['Foo'] == 'bar'
def test_implicit_POST_json(self, httpbin):
- r = http(httpbin.url + '/post', 'hello=world')
+ r = http(httpbin + '/post', 'hello=world')
assert HTTP_OK in r
assert r.json['json'] == {'hello': 'world'}
def test_implicit_POST_form(self, httpbin):
- r = http('--form', httpbin.url + '/post', 'foo=bar')
+ r = http('--form', httpbin + '/post', 'foo=bar')
assert HTTP_OK in r
assert r.json['form'] == {'foo': 'bar'}
def test_implicit_POST_raw(self, httpbin):
- r = http('--raw', 'foo bar', httpbin.url + '/post')
+ r = http('--raw', 'foo bar', httpbin + '/post')
assert HTTP_OK in r
assert r.json['data'] == 'foo bar'
@@ -55,7 +55,7 @@ class TestImplicitHTTPMethod:
stdin_isatty=False,
stdin=BytesIO(FILE_PATH.read_bytes())
)
- r = http('--form', httpbin.url + '/post', env=env)
+ r = http('--form', httpbin + '/post', env=env)
assert HTTP_OK in r
@@ -69,33 +69,33 @@ class TestAutoContentTypeAndAcceptHeaders:
def test_GET_no_data_no_auto_headers(self, httpbin):
# https://github.com/httpie/cli/issues/62
- r = http('GET', httpbin.url + '/headers')
+ r = http('GET', httpbin + '/headers')
assert HTTP_OK in r
assert r.json['headers']['Accept'] == '*/*'
assert 'Content-Type' not in r.json['headers']
def test_POST_no_data_no_auto_headers(self, httpbin):
# JSON headers shouldn't be automatically set for POST with no data.
- r = http('POST', httpbin.url + '/post')
+ r = http('POST', httpbin + '/post')
assert HTTP_OK in r
assert '"Accept": "*/*"' in r
assert '"Content-Type": "application/json' not in r
def test_POST_with_data_auto_JSON_headers(self, httpbin):
- r = http('POST', httpbin.url + '/post', 'a=b')
+ r = http('POST', httpbin + '/post', 'a=b')
assert HTTP_OK in r
assert r.json['headers']['Accept'] == JSON_ACCEPT
assert r.json['headers']['Content-Type'] == 'application/json'
def test_GET_with_data_auto_JSON_headers(self, httpbin):
# JSON headers should automatically be set also for GET with data.
- r = http('POST', httpbin.url + '/post', 'a=b')
+ r = http('POST', httpbin + '/post', 'a=b')
assert HTTP_OK in r
assert r.json['headers']['Accept'] == JSON_ACCEPT
assert r.json['headers']['Content-Type'] == 'application/json'
def test_POST_explicit_JSON_JSON_ACCEPT(self, httpbin):
- r = http('--json', 'POST', httpbin.url + '/post')
+ r = http('--json', 'POST', httpbin + '/post')
assert HTTP_OK in r
assert r.json['headers']['Accept'] == JSON_ACCEPT
# Make sure Content-Type gets set even with no data.
@@ -103,7 +103,7 @@ class TestAutoContentTypeAndAcceptHeaders:
assert 'application/json' in r.json['headers']['Content-Type']
def test_GET_explicit_JSON_explicit_headers(self, httpbin):
- r = http('--json', 'GET', httpbin.url + '/headers',
+ r = http('--json', 'GET', httpbin + '/headers',
'Accept:application/xml',
'Content-Type:application/xml')
assert HTTP_OK in r
@@ -111,22 +111,22 @@ class TestAutoContentTypeAndAcceptHeaders:
assert '"Content-Type": "application/xml"' in r
def test_POST_form_auto_Content_Type(self, httpbin):
- r = http('--form', 'POST', httpbin.url + '/post')
+ r = http('--form', 'POST', httpbin + '/post')
assert HTTP_OK in r
assert '"Content-Type": "application/x-www-form-urlencoded' in r
def test_POST_form_Content_Type_override(self, httpbin):
- r = http('--form', 'POST', httpbin.url + '/post',
+ r = http('--form', 'POST', httpbin + '/post',
'Content-Type:application/xml')
assert HTTP_OK in r
assert '"Content-Type": "application/xml"' in r
def test_print_only_body_when_stdout_redirected_by_default(self, httpbin):
env = MockEnvironment(stdin_isatty=True, stdout_isatty=False)
- r = http('GET', httpbin.url + '/get', env=env)
+ r = http('GET', httpbin + '/get', env=env)
assert 'HTTP/' not in r
def test_print_overridable_when_stdout_redirected(self, httpbin):
env = MockEnvironment(stdin_isatty=True, stdout_isatty=False)
- r = http('--print=h', 'GET', httpbin.url + '/get', env=env)
+ r = http('--print=h', 'GET', httpbin + '/get', env=env)
assert HTTP_OK in r
diff --git a/tests/test_downloads.py b/tests/test_downloads.py
index d6e98867..b646a0e6 100644
--- a/tests/test_downloads.py
+++ b/tests/test_downloads.py
@@ -255,7 +255,7 @@ class TestDownloads:
os.chdir(tmp_dirname)
try:
assert os.listdir('.') == []
- http('--download', httpbin.url + '/redirect/1')
+ http('--download', httpbin + '/redirect/1')
assert os.listdir('.') == [expected_filename]
finally:
os.chdir(orig_cwd)
diff --git a/tests/test_encoding.py b/tests/test_encoding.py
index e9f50dc9..62814161 100644
--- a/tests/test_encoding.py
+++ b/tests/test_encoding.py
@@ -31,90 +31,90 @@ def test_charset_text_pairs():
def test_unicode_headers(httpbin):
# httpbin doesn't interpret UFT-8 headers
- r = http(httpbin.url + '/headers', f'Test:{UNICODE}')
+ r = http(httpbin + '/headers', f'Test:{UNICODE}')
assert HTTP_OK in r
def test_unicode_headers_verbose(httpbin):
# httpbin doesn't interpret UTF-8 headers
- r = http('--verbose', httpbin.url + '/headers', f'Test:{UNICODE}')
+ r = http('--verbose', httpbin + '/headers', f'Test:{UNICODE}')
assert HTTP_OK in r
assert UNICODE in r
def test_unicode_raw(httpbin):
- r = http('--raw', f'test {UNICODE}', 'POST', httpbin.url + '/post')
+ r = http('--raw', f'test {UNICODE}', 'POST', httpbin + '/post')
assert HTTP_OK in r
assert r.json['data'] == f'test {UNICODE}'
def test_unicode_raw_verbose(httpbin):
r = http('--verbose', '--raw', f'test {UNICODE}',
- 'POST', httpbin.url + '/post')
+ 'POST', httpbin + '/post')
assert HTTP_OK in r
assert UNICODE in r
def test_unicode_form_item(httpbin):
- r = http('--form', 'POST', httpbin.url + '/post', f'test={UNICODE}')
+ r = http('--form', 'POST', httpbin + '/post', f'test={UNICODE}')
assert HTTP_OK in r
assert r.json['form'] == {'test': UNICODE}
def test_unicode_form_item_verbose(httpbin):
r = http('--verbose', '--form',
- 'POST', httpbin.url + '/post', f'test={UNICODE}')
+ 'POST', httpbin + '/post', f'test={UNICODE}')
assert HTTP_OK in r
assert UNICODE in r
def test_unicode_json_item(httpbin):
- r = http('--json', 'POST', httpbin.url + '/post', f'test={UNICODE}')
+ r = http('--json', 'POST', httpbin + '/post', f'test={UNICODE}')
assert HTTP_OK in r
assert r.json['json'] == {'test': UNICODE}
def test_unicode_json_item_verbose(httpbin):
r = http('--verbose', '--json',
- 'POST', httpbin.url + '/post', f'test={UNICODE}')
+ 'POST', httpbin + '/post', f'test={UNICODE}')
assert HTTP_OK in r
assert UNICODE in r
def test_unicode_raw_json_item(httpbin):
- r = http('--json', 'POST', httpbin.url + '/post',
+ r = http('--json', 'POST', httpbin + '/post',
f'test:={{ "{UNICODE}" : [ "{UNICODE}" ] }}')
assert HTTP_OK in r
assert r.json['json'] == {'test': {UNICODE: [UNICODE]}}
def test_unicode_raw_json_item_verbose(httpbin):
- r = http('--json', 'POST', httpbin.url + '/post',
+ r = http('--json', 'POST', httpbin + '/post',
f'test:={{ "{UNICODE}" : [ "{UNICODE}" ] }}')
assert HTTP_OK in r
assert r.json['json'] == {'test': {UNICODE: [UNICODE]}}
def test_unicode_url_query_arg_item(httpbin):
- r = http(httpbin.url + '/get', f'test=={UNICODE}')
+ r = http(httpbin + '/get', f'test=={UNICODE}')
assert HTTP_OK in r
assert r.json['args'] == {'test': UNICODE}, r
def test_unicode_url_query_arg_item_verbose(httpbin):
- r = http('--verbose', httpbin.url + '/get', f'test=={UNICODE}')
+ r = http('--verbose', httpbin + '/get', f'test=={UNICODE}')
assert HTTP_OK in r
assert UNICODE in r
def test_unicode_url(httpbin):
- r = http(f'{httpbin.url}/get?test={UNICODE}')
+ r = http(f'{httpbin}/get?test={UNICODE}')
assert HTTP_OK in r
assert r.json['args'] == {'test': UNICODE}
def test_unicode_url_verbose(httpbin):
- r = http('--verbose', f'{httpbin.url}/get?test={UNICODE}')
+ r = http('--verbose', f'{httpbin}/get?test={UNICODE}')
assert HTTP_OK in r
assert r.json['args'] == {'test': UNICODE}
@@ -123,7 +123,7 @@ def test_unicode_basic_auth(httpbin):
# it doesn't really authenticate us because httpbin
# doesn't interpret the UTF-8-encoded auth
http('--verbose', '--auth', f'test:{UNICODE}',
- f'{httpbin.url}/basic-auth/test/{UNICODE}')
+ f'{httpbin}/basic-auth/test/{UNICODE}')
def test_unicode_digest_auth(httpbin):
@@ -131,7 +131,7 @@ def test_unicode_digest_auth(httpbin):
# doesn't interpret the UTF-8-encoded auth
http('--auth-type=digest',
'--auth', f'test:{UNICODE}',
- f'{httpbin.url}/digest-auth/auth/test/{UNICODE}')
+ f'{httpbin}/digest-auth/auth/test/{UNICODE}')
@pytest.mark.parametrize('charset, text', CHARSET_TEXT_PAIRS)
diff --git a/tests/test_exit_status.py b/tests/test_exit_status.py
index 4438d348..02fd2f1f 100644
--- a/tests/test_exit_status.py
+++ b/tests/test_exit_status.py
@@ -7,25 +7,25 @@ from .utils import MockEnvironment, http, HTTP_OK
def test_keyboard_interrupt_during_arg_parsing_exit_status(httpbin):
with mock.patch('httpie.cli.definition.parser.parse_args',
side_effect=KeyboardInterrupt()):
- r = http('GET', httpbin.url + '/get', tolerate_error_exit_status=True)
+ r = http('GET', httpbin + '/get', tolerate_error_exit_status=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 + '/get', tolerate_error_exit_status=True)
+ r = http('GET', httpbin + '/get', tolerate_error_exit_status=True)
assert r.exit_status == ExitStatus.ERROR_CTRL_C
def test_ok_response_exits_0(httpbin):
- r = http('GET', httpbin.url + '/get')
+ r = http('GET', httpbin + '/get')
assert HTTP_OK in r
assert r.exit_status == ExitStatus.SUCCESS
def test_error_response_exits_0_without_check_status(httpbin):
- r = http('GET', httpbin.url + '/status/500')
+ r = http('GET', httpbin + '/status/500')
assert '500 INTERNAL SERVER ERROR' in r
assert r.exit_status == ExitStatus.SUCCESS
assert not r.stderr
@@ -33,7 +33,7 @@ def test_error_response_exits_0_without_check_status(httpbin):
def test_timeout_exit_status(httpbin):
- r = http('--timeout=0.01', 'GET', httpbin.url + '/delay/0.5',
+ r = http('--timeout=0.01', 'GET', httpbin + '/delay/0.5',
tolerate_error_exit_status=True)
assert r.exit_status == ExitStatus.ERROR_TIMEOUT
@@ -42,7 +42,7 @@ def test_3xx_check_status_exits_3_and_stderr_when_stdout_redirected(
httpbin):
env = MockEnvironment(stdout_isatty=False)
r = http('--check-status', '--headers',
- 'GET', httpbin.url + '/status/301',
+ 'GET', httpbin + '/status/301',
env=env, tolerate_error_exit_status=True)
assert '301 MOVED PERMANENTLY' in r
assert r.exit_status == ExitStatus.ERROR_HTTP_3XX
@@ -51,7 +51,7 @@ def test_3xx_check_status_exits_3_and_stderr_when_stdout_redirected(
def test_3xx_check_status_redirects_allowed_exits_0(httpbin):
r = http('--check-status', '--follow',
- 'GET', httpbin.url + '/status/301',
+ 'GET', httpbin + '/status/301',
tolerate_error_exit_status=True)
# The redirect will be followed so 200 is expected.
assert HTTP_OK in r
@@ -59,7 +59,7 @@ def test_3xx_check_status_redirects_allowed_exits_0(httpbin):
def test_4xx_check_status_exits_4(httpbin):
- r = http('--check-status', 'GET', httpbin.url + '/status/401',
+ r = http('--check-status', 'GET', httpbin + '/status/401',
tolerate_error_exit_status=True)
assert '401 UNAUTHORIZED' in r
assert r.exit_status == ExitStatus.ERROR_HTTP_4XX
@@ -68,7 +68,7 @@ def test_4xx_check_status_exits_4(httpbin):
def test_5xx_check_status_exits_5(httpbin):
- r = http('--check-status', 'GET', httpbin.url + '/status/500',
+ r = http('--check-status', 'GET', httpbin + '/status/500',
tolerate_error_exit_status=True)
assert '500 INTERNAL SERVER ERROR' in r
assert r.exit_status == ExitStatus.ERROR_HTTP_5XX
diff --git a/tests/test_output.py b/tests/test_output.py
index f85f38fa..2242177d 100644
--- a/tests/test_output.py
+++ b/tests/test_output.py
@@ -54,7 +54,7 @@ class TestQuietFlag:
stdout_isatty=True,
devnull=io.BytesIO()
)
- r = http(*quiet_flags, 'GET', httpbin.url + '/get', env=env)
+ r = http(*quiet_flags, 'GET', httpbin + '/get', env=env)
assert env.stdout is env.devnull
assert env.stderr is env.devnull
assert HTTP_OK in r.devnull
@@ -134,7 +134,7 @@ class TestQuietFlag:
)
r = http(
*quiet_flags, '--auth', 'user', 'GET',
- httpbin.url + '/basic-auth/user/password',
+ httpbin + '/basic-auth/user/password',
env=env
)
assert env.stdout is env.devnull
@@ -147,7 +147,7 @@ class TestQuietFlag:
@pytest.mark.parametrize('output_options', ['-h', '-b', '-v', '-p=hH'])
def test_quiet_with_explicit_output_options(self, httpbin, quiet_flags, output_options):
env = MockEnvironment(stdin_isatty=True, stdout_isatty=True)
- r = http(*quiet_flags, output_options, httpbin.url + '/get', env=env)
+ r = http(*quiet_flags, output_options, httpbin + '/get', env=env)
assert env.stdout is env.devnull
assert env.stderr is env.devnull
assert r == ''
@@ -188,26 +188,26 @@ class TestQuietFlag:
class TestVerboseFlag:
def test_verbose(self, httpbin):
r = http('--verbose',
- 'GET', httpbin.url + '/get', 'test-header:__test__')
+ 'GET', httpbin + '/get', 'test-header:__test__')
assert HTTP_OK in r
assert r.count('__test__') == 2
def test_verbose_raw(self, httpbin):
r = http('--verbose', '--raw', 'foo bar',
- 'POST', httpbin.url + '/post')
+ 'POST', httpbin + '/post')
assert HTTP_OK in r
assert 'foo bar' in r
def test_verbose_form(self, httpbin):
# https://github.com/httpie/cli/issues/53
- r = http('--verbose', '--form', 'POST', httpbin.url + '/post',
+ r = http('--verbose', '--form', 'POST', httpbin + '/post',
'A=B', 'C=D')
assert HTTP_OK in r
assert 'A=B&C=D' in r
def test_verbose_json(self, httpbin):
r = http('--verbose',
- 'POST', httpbin.url + '/post', 'foo=bar', 'baz=bar')
+ 'POST', httpbin + '/post', 'foo=bar', 'baz=bar')
assert HTTP_OK in r
assert '"baz": "bar"' in r
@@ -290,20 +290,20 @@ class TestPrettyOptions:
def test_pretty_enabled_by_default(self, httpbin):
env = MockEnvironment(colors=256)
- r = http('GET', httpbin.url + '/get', env=env)
+ r = http('GET', httpbin + '/get', env=env)
assert COLOR in r
def test_pretty_enabled_by_default_unless_stdout_redirected(self, httpbin):
- r = http('GET', httpbin.url + '/get')
+ r = http('GET', httpbin + '/get')
assert COLOR not in r
def test_force_pretty(self, httpbin):
env = MockEnvironment(stdout_isatty=False, colors=256)
- r = http('--pretty=all', 'GET', httpbin.url + '/get', env=env)
+ r = http('--pretty=all', 'GET', httpbin + '/get', env=env)
assert COLOR in r
def test_force_ugly(self, httpbin):
- r = http('--pretty=none', 'GET', httpbin.url + '/get')
+ r = http('--pretty=none', 'GET', httpbin + '/get')
assert COLOR not in r
def test_subtype_based_pygments_lexer_match(self, httpbin):
@@ -312,14 +312,14 @@ class TestPrettyOptions:
"""
env = MockEnvironment(colors=256)
- r = http('--print=B', '--pretty=all', httpbin.url + '/post',
+ r = http('--print=B', '--pretty=all', httpbin + '/post',
'Content-Type:text/foo+json', 'a=b', env=env)
assert COLOR in r
def test_colors_option(self, httpbin):
env = MockEnvironment(colors=256)
r = http('--print=B', '--pretty=colors',
- 'GET', httpbin.url + '/get', 'a=b',
+ 'GET', httpbin + '/get', 'a=b',
env=env)
# Tests that the JSON data isn't formatted.
assert not r.strip().count('\n')
@@ -328,7 +328,7 @@ class TestPrettyOptions:
def test_format_option(self, httpbin):
env = MockEnvironment(colors=256)
r = http('--print=B', '--pretty=format',
- 'GET', httpbin.url + '/get', 'a=b',
+ 'GET', httpbin + '/get', 'a=b',
env=env)
# Tests that the JSON data is formatted.
assert r.strip().count('\n') == 2
@@ -355,25 +355,25 @@ class TestLineEndings:
return body
def test_CRLF_headers_only(self, httpbin):
- r = http('--headers', 'GET', httpbin.url + '/get')
+ r = http('--headers', 'GET', httpbin + '/get')
body = self._validate_crlf(r)
assert not body, f'Garbage after headers: {r!r}'
def test_CRLF_ugly_response(self, httpbin):
- r = http('--pretty=none', 'GET', httpbin.url + '/get')
+ r = http('--pretty=none', 'GET', httpbin + '/get')
self._validate_crlf(r)
def test_CRLF_formatted_response(self, httpbin):
- r = http('--pretty=format', 'GET', httpbin.url + '/get')
+ r = http('--pretty=format', 'GET', httpbin + '/get')
assert r.exit_status == ExitStatus.SUCCESS
self._validate_crlf(r)
def test_CRLF_ugly_request(self, httpbin):
- r = http('--pretty=none', '--print=HB', 'GET', httpbin.url + '/get')
+ r = http('--pretty=none', '--print=HB', 'GET', httpbin + '/get')
self._validate_crlf(r)
def test_CRLF_formatted_request(self, httpbin):
- r = http('--pretty=format', '--print=HB', 'GET', httpbin.url + '/get')
+ r = http('--pretty=format', '--print=HB', 'GET', httpbin + '/get')
self._validate_crlf(r)
diff --git a/tests/test_redirects.py b/tests/test_redirects.py
index a761fa25..f993f311 100644
--- a/tests/test_redirects.py
+++ b/tests/test_redirects.py
@@ -13,7 +13,7 @@ REDIRECTS_WITH_METHOD_BODY_PRESERVED = [307, 308]
def test_follow_all_redirects_shown(httpbin):
- r = http('--follow', '--all', httpbin.url + '/redirect/2')
+ r = http('--follow', '--all', httpbin + '/redirect/2')
assert r.count('HTTP/1.1') == 3
assert r.count('HTTP/1.1 302 FOUND', 2)
assert HTTP_OK in r
@@ -21,14 +21,14 @@ def test_follow_all_redirects_shown(httpbin):
@pytest.mark.parametrize('follow_flag', ['--follow', '-F'])
def test_follow_without_all_redirects_hidden(httpbin, follow_flag):
- r = http(follow_flag, httpbin.url + '/redirect/2')
+ r = http(follow_flag, httpbin + '/redirect/2')
assert r.count('HTTP/1.1') == 1
assert HTTP_OK in r
@pytest.mark.xfail(True, reason="https://github.com/httpie/cli/issues/1082")
def test_follow_output_options_used_for_redirects(httpbin):
- r = http('--follow', '--print=H', httpbin.url + '/redirect/2')
+ r = http('--follow', '--print=H', httpbin + '/redirect/2')
assert r.count('GET /') == 1
assert HTTP_OK not in r
@@ -38,7 +38,7 @@ def test_follow_all_output_options_used_for_redirects(httpbin):
'--follow',
'--all',
'--print=H',
- httpbin.url + '/redirect/2')
+ httpbin + '/redirect/2')
assert r.count('GET /') == 3
assert HTTP_OK not in r
@@ -50,7 +50,7 @@ def test_follow_all_output_options_used_for_redirects(httpbin):
# '--all',
# '--print=h',
# '--history-print=H',
-# httpbin.url + '/redirect/2')
+# httpbin + '/redirect/2')
# assert r.count('GET /') == 2
# assert 'HTTP/1.1 302 FOUND' not in r
# assert HTTP_OK in r
@@ -61,7 +61,7 @@ def test_max_redirects(httpbin):
r = http(
'--max-redirects=1',
'--follow',
- httpbin.url + '/redirect/3',
+ httpbin + '/redirect/3',
tolerate_error_exit_status=True,
)
assert r.exit_status == ExitStatus.ERROR_TOO_MANY_REDIRECTS
@@ -72,11 +72,11 @@ def test_max_redirects(httpbin):
def test_follow_redirect_with_repost(httpbin, status_code):
r = http(
'--follow',
- httpbin.url + '/redirect-to',
+ httpbin + '/redirect-to',
'A:A',
'A:B',
'B:B',
- f'url=={httpbin.url}/post',
+ f'url=={httpbin}/post',
f'status_code=={status_code}',
'@' + FILE_PATH_ARG,
)
@@ -92,11 +92,11 @@ def test_verbose_follow_redirect_with_repost(httpbin, status_code):
r = http(
'--follow',
'--verbose',
- httpbin.url + '/redirect-to',
+ httpbin + '/redirect-to',
'A:A',
'A:B',
'B:B',
- f'url=={httpbin.url}/post',
+ f'url=={httpbin}/post',
f'status_code=={status_code}',
'@' + FILE_PATH_ARG,
)
diff --git a/tests/test_regressions.py b/tests/test_regressions.py
index 07d60a58..622d03d7 100644
--- a/tests/test_regressions.py
+++ b/tests/test_regressions.py
@@ -12,7 +12,7 @@ def test_Host_header_overwrite(httpbin):
"""
host = 'pie.dev'
- url = httpbin.url + '/get'
+ url = httpbin + '/get'
r = http('--print=hH', url, f'host:{host}')
assert HTTP_OK in r
assert r.lower().count('host:') == 1
@@ -35,7 +35,7 @@ def test_verbose_redirected_stdout_separator(httpbin):
"""
r = http(
'-v',
- httpbin.url + '/post',
+ httpbin + '/post',
'a=b',
env=MockEnvironment(stdout_isatty=False),
)
diff --git a/tests/test_sessions.py b/tests/test_sessions.py
index 6c2c6f0e..aa524348 100644
--- a/tests/test_sessions.py
+++ b/tests/test_sessions.py
@@ -82,7 +82,7 @@ class TestSessionFlow(SessionTestBase):
'--session=test',
'--auth=username:password',
'GET',
- httpbin.url + '/cookies/set?hello=world',
+ httpbin + '/cookies/set?hello=world',
'Hello:World',
env=self.env()
)
@@ -92,7 +92,7 @@ class TestSessionFlow(SessionTestBase):
self.start_session(httpbin)