httpie-cli/tests/test_regressions.py

50 lines
1.2 KiB
Python
Raw Normal View History

2014-06-28 13:24:14 +02:00
"""Miscellaneous regression tests"""
import pytest
2014-06-28 13:24:14 +02:00
from httpie.compat import is_windows
from tests.utils.matching import assert_output_matches, Expect
2020-12-22 22:56:45 +01:00
from utils import HTTP_OK, MockEnvironment, http
2014-06-28 13:24:14 +02:00
def test_Host_header_overwrite(httpbin):
2014-06-28 13:24:14 +02:00
"""
2020-12-23 22:07:27 +01:00
https://github.com/httpie/httpie/issues/235
2014-06-28 13:24:14 +02:00
"""
2020-12-24 21:34:30 +01:00
host = 'pie.dev'
2016-10-26 11:28:17 +02:00
url = httpbin.url + '/get'
r = http('--print=hH', url, 'host:{0}'.format(host))
2014-06-28 13:24:14 +02:00
assert HTTP_OK in r
assert r.lower().count('host:') == 1
assert 'host: {0}'.format(host) in r
@pytest.mark.skipif(is_windows, reason='Unix-only')
def test_output_devnull(httpbin):
"""
2020-12-23 22:07:27 +01:00
https://github.com/httpie/httpie/issues/252
"""
http('--output=/dev/null', httpbin + '/get')
2020-12-22 22:56:45 +01:00
def test_verbose_redirected_stdout_separator(httpbin):
"""
<https://github.com/httpie/httpie/issues/1006>
"""
r = http(
'-v',
httpbin.url + '/post',
'a=b',
env=MockEnvironment(stdout_isatty=False),
)
assert '}HTTP/' not in r
assert_output_matches(r, [
Expect.REQUEST_HEADERS,
Expect.BODY,
Expect.SEPARATOR,
Expect.RESPONSE_HEADERS,
Expect.BODY,
])