mirror of
https://github.com/httpie/cli.git
synced 2025-06-28 13:31:41 +02: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 os
|
||||||
|
import codecs
|
||||||
|
|
||||||
from tests import TESTS_ROOT
|
from tests import TESTS_ROOT
|
||||||
from httpie.compat import bytes
|
|
||||||
|
|
||||||
|
|
||||||
def patharg(path):
|
def patharg(path):
|
||||||
@ -18,15 +18,17 @@ FILE_PATH_ARG = patharg(FILE_PATH)
|
|||||||
BIN_FILE_PATH_ARG = patharg(BIN_FILE_PATH)
|
BIN_FILE_PATH_ARG = patharg(BIN_FILE_PATH)
|
||||||
JSON_FILE_PATH_ARG = patharg(JSON_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
|
# 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
|
# easily count occurrences also when embedded in JSON (where the new
|
||||||
# line would be escaped).
|
# line would be escaped).
|
||||||
FILE_CONTENT = f.read().strip()
|
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:
|
with open(BIN_FILE_PATH, 'rb') as f:
|
||||||
BIN_FILE_CONTENT = f.read()
|
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
|
# Parsed data
|
||||||
raw_json_embed = data.pop('raw-json-embed')
|
raw_json_embed = data.pop('raw-json-embed')
|
||||||
assert raw_json_embed == json.loads(
|
assert raw_json_embed == json.loads(JSON_FILE_CONTENT)
|
||||||
JSON_FILE_CONTENT.decode('utf8'))
|
|
||||||
data['string-embed'] = data['string-embed'].strip()
|
data['string-embed'] = data['string-embed'].strip()
|
||||||
assert dict(data) == {
|
assert dict(data) == {
|
||||||
"ed": "",
|
"ed": "",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user