mirror of
https://github.com/httpie/cli.git
synced 2025-02-16 17:40:51 +01:00
Fixed fixture loading on Windows.
This commit is contained in:
parent
84a521a827
commit
bbc820bf2e
16
tests/fixtures/__init__.py
vendored
16
tests/fixtures/__init__.py
vendored
@ -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()
|
||||
|
@ -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": "",
|
||||
|
Loading…
Reference in New Issue
Block a user