Uniformize UTF-8 naming (#1115)

* 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
This commit is contained in:
Mickaël Schoentgen
2021-08-05 20:58:43 +02:00
committed by GitHub
parent 11399dde76
commit c6cbc7dfa5
21 changed files with 54 additions and 42 deletions

View File

@@ -15,6 +15,7 @@ from httpie.cli.argtypes import (
parse_format_options,
)
from httpie.cli.definition import parser
from httpie.constants import UTF8
from httpie.output.formatters.colors import get_lexer
from httpie.status import ExitStatus
from .utils import COLOR, CRLF, HTTP_OK, MockEnvironment, http
@@ -30,7 +31,7 @@ def test_output_option(tmp_path, httpbin, stdout_isatty):
assert r == ''
expected_body = urlopen(url).read().decode()
actual_body = output_filename.read_text()
actual_body = output_filename.read_text(encoding=UTF8)
assert actual_body == expected_body
@@ -125,7 +126,7 @@ class TestQuietFlag:
assert env.stdout is env.devnull
else:
assert env.stdout is not env.devnull # --output swaps stdout.
assert output_path.read_text() == output
assert output_path.read_text(encoding=UTF8) == output
finally:
os.chdir(orig_cwd)