mirror of
https://github.com/httpie/cli.git
synced 2025-06-24 19:41:23 +02:00
Fixed a bytes/str issue for Python 3.
This commit is contained in:
parent
d5bc564e4f
commit
0bcd4d2fb0
@ -596,7 +596,7 @@ def parse_items(items, data=None, headers=None, files=None, params=None):
|
|||||||
if item.sep in SEP_GROUP_DATA_EMBED_ITEMS:
|
if item.sep in SEP_GROUP_DATA_EMBED_ITEMS:
|
||||||
try:
|
try:
|
||||||
with open(os.path.expanduser(value), 'rb') as f:
|
with open(os.path.expanduser(value), 'rb') as f:
|
||||||
value = f.read()
|
value = f.read().decode('utf8')
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
raise ParseError('%s": %s' % (item.orig, e))
|
raise ParseError('%s": %s' % (item.orig, e))
|
||||||
|
|
||||||
|
@ -1242,7 +1242,8 @@ class ItemParsingTest(BaseTestCase):
|
|||||||
|
|
||||||
# Parsed data
|
# Parsed data
|
||||||
raw_json_embed = data.pop('raw-json-embed')
|
raw_json_embed = data.pop('raw-json-embed')
|
||||||
self.assertDictEqual(raw_json_embed, json.loads(JSON_FILE_CONTENT))
|
self.assertDictEqual(raw_json_embed, json.loads(
|
||||||
|
JSON_FILE_CONTENT.decode('utf8')))
|
||||||
data['string-embed'] = data['string-embed'].strip()
|
data['string-embed'] = data['string-embed'].strip()
|
||||||
self.assertDictEqual(dict(data), {
|
self.assertDictEqual(dict(data), {
|
||||||
"ed": "",
|
"ed": "",
|
||||||
@ -1260,7 +1261,8 @@ class ItemParsingTest(BaseTestCase):
|
|||||||
|
|
||||||
# Parsed file fields
|
# Parsed file fields
|
||||||
self.assertIn('file', files)
|
self.assertIn('file', files)
|
||||||
self.assertEqual(files['file'][1].read().strip(), FILE_CONTENT)
|
self.assertEqual(files['file'][1].read().strip().decode('utf8'),
|
||||||
|
FILE_CONTENT)
|
||||||
|
|
||||||
|
|
||||||
class ArgumentParserTestCase(unittest.TestCase):
|
class ArgumentParserTestCase(unittest.TestCase):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user