mirror of
https://github.com/httpie/cli.git
synced 2025-01-12 00:28:41 +01:00
More unicode tests.
This commit is contained in:
parent
77dcd6e919
commit
3478cbd9ff
10
tests/fixtures/__init__.py
vendored
10
tests/fixtures/__init__.py
vendored
@ -1,6 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from tests import TESTS_ROOT
|
from tests import TESTS_ROOT
|
||||||
|
from httpie.compat import bytes
|
||||||
|
|
||||||
|
|
||||||
def patharg(path):
|
def patharg(path):
|
||||||
@ -9,13 +10,11 @@ def patharg(path):
|
|||||||
|
|
||||||
|
|
||||||
### Test files
|
### Test files
|
||||||
FILE_PATH = os.path.join(TESTS_ROOT, 'fixtures', 'file.txt')
|
FILE_PATH = os.path.join(TESTS_ROOT, 'fixtures', 'test.txt')
|
||||||
FILE2_PATH = os.path.join(TESTS_ROOT, 'fixtures', 'file2.txt')
|
|
||||||
BIN_FILE_PATH = os.path.join(TESTS_ROOT, 'fixtures', 'file.bin')
|
|
||||||
JSON_FILE_PATH = os.path.join(TESTS_ROOT, 'fixtures', 'test.json')
|
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)
|
FILE_PATH_ARG = patharg(FILE_PATH)
|
||||||
FILE2_PATH_ARG = patharg(FILE2_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)
|
||||||
|
|
||||||
@ -24,6 +23,9 @@ with open(FILE_PATH) as f:
|
|||||||
# 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 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:
|
with open(JSON_FILE_PATH, 'rb') as f:
|
||||||
|
1
tests/fixtures/file.txt
vendored
1
tests/fixtures/file.txt
vendored
@ -1 +0,0 @@
|
|||||||
__test_file_content__
|
|
1
tests/fixtures/file2.txt
vendored
1
tests/fixtures/file2.txt
vendored
@ -1 +0,0 @@
|
|||||||
__test_file_content__
|
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
1
tests/fixtures/test.txt
vendored
Normal file
1
tests/fixtures/test.txt
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
some UTF8-encoded unicode text 太陽 by Jakub Roztočil
|
@ -32,7 +32,7 @@ class TestRequestBodyFromFilePath:
|
|||||||
def test_request_body_from_file_by_path(self):
|
def test_request_body_from_file_by_path(self):
|
||||||
r = http('--verbose', 'POST', httpbin('/post'), '@' + FILE_PATH_ARG)
|
r = http('--verbose', 'POST', httpbin('/post'), '@' + FILE_PATH_ARG)
|
||||||
assert HTTP_OK in r
|
assert HTTP_OK in r
|
||||||
assert FILE_CONTENT in r
|
assert FILE_CONTENT in r, r
|
||||||
assert '"Content-Type": "text/plain"' in r
|
assert '"Content-Type": "text/plain"' in r
|
||||||
|
|
||||||
def test_request_body_from_file_by_path_with_explicit_content_type(self):
|
def test_request_body_from_file_by_path_with_explicit_content_type(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user