diff --git a/tests/fixtures/__init__.py b/tests/fixtures/__init__.py index 6e1724e1..2ffdf89f 100644 --- a/tests/fixtures/__init__.py +++ b/tests/fixtures/__init__.py @@ -1,7 +1,7 @@ import os +import codecs from tests import TESTS_ROOT -from httpie.compat import bytes def patharg(path): @@ -18,15 +18,17 @@ FILE_PATH_ARG = patharg(FILE_PATH) BIN_FILE_PATH_ARG = patharg(BIN_FILE_PATH) JSON_FILE_PATH_ARG = patharg(JSON_FILE_PATH) -with open(FILE_PATH) as f: + +with codecs.open(FILE_PATH, encoding='utf8') as f: # Strip because we don't want new lines in the data so that we can # easily count occurrences also when embedded in JSON (where the new # line would be escaped). FILE_CONTENT = f.read().strip() - if isinstance(FILE_CONTENT, bytes): - # Python < 3.0 - FILE_CONTENT = FILE_CONTENT.decode('utf8') + + +with codecs.open(JSON_FILE_PATH, encoding='utf8') as f: + JSON_FILE_CONTENT = f.read() + + with open(BIN_FILE_PATH, 'rb') as f: BIN_FILE_CONTENT = f.read() -with open(JSON_FILE_PATH, 'rb') as f: - JSON_FILE_CONTENT = f.read() diff --git a/tests/test_cli.py b/tests/test_cli.py index 75854c37..cd4ea019 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -73,8 +73,7 @@ class TestItemParsing: # Parsed data raw_json_embed = data.pop('raw-json-embed') - assert raw_json_embed == json.loads( - JSON_FILE_CONTENT.decode('utf8')) + assert raw_json_embed == json.loads(JSON_FILE_CONTENT) data['string-embed'] = data['string-embed'].strip() assert dict(data) == { "ed": "",