You've already forked httpie-cli
mirror of
https://github.com/httpie/cli.git
synced 2025-08-10 22:42:05 +02:00
More unicode tests.
This commit is contained in:
10
tests/fixtures/__init__.py
vendored
10
tests/fixtures/__init__.py
vendored
@@ -1,6 +1,7 @@
|
||||
import os
|
||||
|
||||
from tests import TESTS_ROOT
|
||||
from httpie.compat import bytes
|
||||
|
||||
|
||||
def patharg(path):
|
||||
@@ -9,13 +10,11 @@ def patharg(path):
|
||||
|
||||
|
||||
### Test files
|
||||
FILE_PATH = os.path.join(TESTS_ROOT, 'fixtures', 'file.txt')
|
||||
FILE2_PATH = os.path.join(TESTS_ROOT, 'fixtures', 'file2.txt')
|
||||
BIN_FILE_PATH = os.path.join(TESTS_ROOT, 'fixtures', 'file.bin')
|
||||
FILE_PATH = os.path.join(TESTS_ROOT, 'fixtures', 'test.txt')
|
||||
JSON_FILE_PATH = os.path.join(TESTS_ROOT, 'fixtures', 'test.json')
|
||||
BIN_FILE_PATH = os.path.join(TESTS_ROOT, 'fixtures', 'test.bin')
|
||||
|
||||
FILE_PATH_ARG = patharg(FILE_PATH)
|
||||
FILE2_PATH_ARG = patharg(FILE2_PATH)
|
||||
BIN_FILE_PATH_ARG = patharg(BIN_FILE_PATH)
|
||||
JSON_FILE_PATH_ARG = patharg(JSON_FILE_PATH)
|
||||
|
||||
@@ -24,6 +23,9 @@ with open(FILE_PATH) as f:
|
||||
# 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 open(BIN_FILE_PATH, 'rb') as f:
|
||||
BIN_FILE_CONTENT = f.read()
|
||||
with open(JSON_FILE_PATH, 'rb') as f:
|
||||
|
Reference in New Issue
Block a user