Skip to content
Myr

Simplify bytes to hex string conversion (#1049)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Taneli Hukkinen · committed by GitHub · parent 2f0e048 · Browse files · 1 file+4 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: Florimond Manca <florimond.manca@gmail.com>

Diff stats

1 file+4 added−5 removed

  • tests:+4 added−5 removed

1 file+4 added−5 removed

modified:tests/test_multipart.py+4 added-5 removed
1import binascii1import cgi2import io3import os4import typing
108 unmodified lines
113 }114 files = {"file": ("name.txt", open(path, "rb"))}115116 with mock.patch("os.urandom", return_value=os.urandom(16)):118 boundary = binascii.hexlify(os.urandom(16)).decode("ascii")117 boundary = os.urandom(16).hex()118119 stream = encode(data=data, files=files)120 assert stream.can_replay()121
17 unmodified lines
139140def test_multipart_encode_files_allows_filenames_as_none() -> None:141 files = {"file": (None, io.BytesIO(b"<file content>"))}142 with mock.patch("os.urandom", return_value=os.urandom(16)):144 boundary = binascii.hexlify(os.urandom(16)).decode("ascii")143 boundary = os.urandom(16).hex()144145 stream = encode(data={}, files=files)146 assert stream.can_replay()147
17 unmodified lines
165 file_name: str, expected_content_type: str166) -> None:167 files = {"file": (file_name, io.BytesIO(b"<file content>"))}168 with mock.patch("os.urandom", return_value=os.urandom(16)):170 boundary = binascii.hexlify(os.urandom(16)).decode("ascii")169 boundary = os.urandom(16).hex()170171 stream = encode(data={}, files=files)172 assert stream.can_replay()173
14 unmodified lines
188 value: typing.Union[str, bytes], output: str189) -> None:190 files = {"file": ("test.txt", value, "text/plain")}191 with mock.patch("os.urandom", return_value=os.urandom(16)):193 boundary = binascii.hexlify(os.urandom(16)).decode("ascii")192 boundary = os.urandom(16).hex()193194 stream = encode(data={}, files=files)195 assert stream.can_replay()196
68 unmodified lines