From: Taneli Hukkinen Date: Sun, 5 Jul 2020 10:16:55 +0000 (+0300) Subject: Simplify bytes to hex string conversion (#1049) X-Git-Tag: 0.14.0~61 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a20cfc0b85cf86bc30cc4d73bbc52ad8c4c7d9e;p=thirdparty%2Fhttpx.git Simplify bytes to hex string conversion (#1049) Co-authored-by: Florimond Manca --- diff --git a/tests/test_multipart.py b/tests/test_multipart.py index 2fc24123..fbabc7c4 100644 --- a/tests/test_multipart.py +++ b/tests/test_multipart.py @@ -1,4 +1,3 @@ -import binascii import cgi import io import os @@ -115,7 +114,7 @@ def test_multipart_encode(tmp_path: typing.Any) -> None: files = {"file": ("name.txt", open(path, "rb"))} with mock.patch("os.urandom", return_value=os.urandom(16)): - boundary = binascii.hexlify(os.urandom(16)).decode("ascii") + boundary = os.urandom(16).hex() stream = encode(data=data, files=files) assert stream.can_replay() @@ -141,7 +140,7 @@ def test_multipart_encode(tmp_path: typing.Any) -> None: def test_multipart_encode_files_allows_filenames_as_none() -> None: files = {"file": (None, io.BytesIO(b""))} with mock.patch("os.urandom", return_value=os.urandom(16)): - boundary = binascii.hexlify(os.urandom(16)).decode("ascii") + boundary = os.urandom(16).hex() stream = encode(data={}, files=files) assert stream.can_replay() @@ -167,7 +166,7 @@ def test_multipart_encode_files_guesses_correct_content_type( ) -> None: files = {"file": (file_name, io.BytesIO(b""))} with mock.patch("os.urandom", return_value=os.urandom(16)): - boundary = binascii.hexlify(os.urandom(16)).decode("ascii") + boundary = os.urandom(16).hex() stream = encode(data={}, files=files) assert stream.can_replay() @@ -190,7 +189,7 @@ def test_multipart_encode_files_allows_bytes_or_str_content( ) -> None: files = {"file": ("test.txt", value, "text/plain")} with mock.patch("os.urandom", return_value=os.urandom(16)): - boundary = binascii.hexlify(os.urandom(16)).decode("ascii") + boundary = os.urandom(16).hex() stream = encode(data={}, files=files) assert stream.can_replay()