mirror of
https://github.com/httpie/cli.git
synced 2024-11-21 23:33:12 +01:00
Fixed and added tests for --verbose with unicode headers.
This commit is contained in:
parent
eca1ffaedb
commit
43bc6d0c98
@ -180,8 +180,12 @@ class HTTPRequest(HTTPMessage):
|
||||
for name, value in headers.items()]
|
||||
|
||||
headers.insert(0, request_line)
|
||||
headers = '\r\n'.join(headers).strip()
|
||||
|
||||
return '\r\n'.join(headers).strip()
|
||||
if isinstance(headers, bytes):
|
||||
# Python < 3
|
||||
headers = headers.decode('utf8')
|
||||
return headers
|
||||
|
||||
@property
|
||||
def encoding(self):
|
||||
|
@ -10,36 +10,68 @@ from tests.fixtures import UNICODE
|
||||
class TestUnicode:
|
||||
|
||||
def test_unicode_headers(self):
|
||||
r = http('GET', httpbin('/headers'), u'Test:%s' % UNICODE)
|
||||
r = http('--verbose', httpbin('/headers'), u'Test:%s' % UNICODE)
|
||||
assert HTTP_OK in r
|
||||
assert r.json['headers']['Test'] == UNICODE
|
||||
|
||||
def test_unicode_headers_verbose(self):
|
||||
r = http('--verbose', httpbin('/headers'), u'Test:%s' % UNICODE)
|
||||
assert HTTP_OK in r
|
||||
assert UNICODE in r
|
||||
|
||||
def test_unicode_form_item(self):
|
||||
r = http('--form', 'POST', httpbin('/post'), u'test=%s' % UNICODE)
|
||||
assert HTTP_OK in r
|
||||
assert r.json['form'] == {'test': UNICODE}
|
||||
|
||||
def test_unicode_form_item_verbose(self):
|
||||
r = http('--verbose', '--form',
|
||||
'POST', httpbin('/post'), u'test=%s' % UNICODE)
|
||||
assert HTTP_OK in r
|
||||
assert UNICODE in r
|
||||
|
||||
def test_unicode_json_item(self):
|
||||
r = http('--json', 'POST', httpbin('/post'), u'test=%s' % UNICODE)
|
||||
assert HTTP_OK in r
|
||||
assert r.json['json'] == {'test': UNICODE}
|
||||
|
||||
def test_unicode_json_item_verbose(self):
|
||||
r = http('--verbose', '--json',
|
||||
'POST', httpbin('/post'), u'test=%s' % UNICODE)
|
||||
assert HTTP_OK in r
|
||||
assert UNICODE in r
|
||||
|
||||
def test_unicode_raw_json_item(self):
|
||||
r = http('--json', 'POST', httpbin('/post'),
|
||||
r = http('--verbose',
|
||||
'--json', 'POST', httpbin('/post'),
|
||||
u'test:={ "%s" : [ "%s" ] }' % (UNICODE, UNICODE))
|
||||
|
||||
def test_unicode_raw_json_item_verbose(self):
|
||||
r = http('--verbose',
|
||||
'--json', 'POST', httpbin('/post'),
|
||||
u'test:={ "%s" : [ "%s" ] }' % (UNICODE, UNICODE))
|
||||
assert HTTP_OK in r
|
||||
assert r.json['json'] == {'test': {UNICODE: [UNICODE]}}
|
||||
assert UNICODE in r
|
||||
|
||||
def test_unicode_url_query_arg_item(self):
|
||||
r = http(httpbin('/get'), u'test==%s' % UNICODE)
|
||||
assert HTTP_OK in r
|
||||
assert r.json['args'] == {'test': UNICODE}, r
|
||||
|
||||
def test_unicode_url_query_arg_item_verbose(self):
|
||||
r = http('--verbose', httpbin('/get'), u'test==%s' % UNICODE)
|
||||
assert HTTP_OK in r
|
||||
assert UNICODE in r
|
||||
|
||||
def test_unicode_url(self):
|
||||
r = http(httpbin(u'/get?test=' + UNICODE))
|
||||
assert HTTP_OK in r
|
||||
assert r.json['args'] == {'test': UNICODE}
|
||||
|
||||
# def test_unicode_url_verbose(self):
|
||||
# r = http(httpbin('--verbose', u'/get?test=' + UNICODE))
|
||||
# assert HTTP_OK in r
|
||||
|
||||
def test_unicode_basic_auth(self):
|
||||
# it doesn't really authenticate us because httpbin
|
||||
# doesn't interpret the utf8-encoded auth
|
||||
|
Loading…
Reference in New Issue
Block a user