Fixed fixture loading on Windows.

This commit is contained in:
Jakub Roztocil 2014-04-26 18:41:28 +02:00
parent 84a521a827
commit bbc820bf2e
2 changed files with 10 additions and 9 deletions

View File

@ -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()

View File

@ -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": "",