mirror of
https://github.com/httpie/cli.git
synced 2024-11-25 17:23:25 +01:00
c6cbc7dfa5
* Uniformize UTF-8 naming
Replace `utf8` -> `utf-8` everywhere.
It should have no impact, `utf8` is an alias of `utf-8` [1].
[1] ee03bad25e/Lib/encodings/aliases.py (L534)
* Always specify the encoding
Let's be explicit over implicit. And prevent future warnings from PEP-597 [1].
[1] https://www.python.org/dev/peps/pep-0597/#using-the-default-encoding-is-a-common-mistake
* Update `UTF8` constant (`utf-8` -> `utf_8`)
* Remove default argument from `str.encode()` and `bytes.decode()`
* Clean-up
34 lines
879 B
Python
34 lines
879 B
Python
"""Test data"""
|
|
from pathlib import Path
|
|
|
|
from httpie.constants import UTF8
|
|
|
|
|
|
def patharg(path):
|
|
"""
|
|
Back slashes need to be escaped in ITEM args,
|
|
even in Windows paths.
|
|
|
|
"""
|
|
return str(path).replace('\\', '\\\\\\')
|
|
|
|
|
|
FIXTURES_ROOT = Path(__file__).parent
|
|
FILE_PATH = FIXTURES_ROOT / 'test.txt'
|
|
JSON_FILE_PATH = FIXTURES_ROOT / 'test.json'
|
|
BIN_FILE_PATH = FIXTURES_ROOT / 'test.bin'
|
|
|
|
FILE_PATH_ARG = patharg(FILE_PATH)
|
|
BIN_FILE_PATH_ARG = patharg(BIN_FILE_PATH)
|
|
JSON_FILE_PATH_ARG = patharg(JSON_FILE_PATH)
|
|
|
|
# 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 = FILE_PATH.read_text(encoding=UTF8).strip()
|
|
|
|
|
|
JSON_FILE_CONTENT = JSON_FILE_PATH.read_text(encoding=UTF8)
|
|
BIN_FILE_CONTENT = BIN_FILE_PATH.read_bytes()
|
|
UNICODE = FILE_CONTENT
|