mirror of
https://github.com/httpie/cli.git
synced 2024-11-08 00:44:45 +01: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:
|
||||
try:
|
||||
with open(os.path.expanduser(value), 'rb') as f:
|
||||
value = f.read()
|
||||
value = f.read().decode('utf8')
|
||||
except IOError as e:
|
||||
raise ParseError('%s": %s' % (item.orig, e))
|
||||
|
||||
|
@ -1242,7 +1242,8 @@ class ItemParsingTest(BaseTestCase):
|
||||
|
||||
# Parsed data
|
||||
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()
|
||||
self.assertDictEqual(dict(data), {
|
||||
"ed": "",
|
||||
@ -1260,7 +1261,8 @@ class ItemParsingTest(BaseTestCase):
|
||||
|
||||
# Parsed file fields
|
||||
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):
|
||||
|
Loading…
Reference in New Issue
Block a user