run string tests with both ascii and utf-8 decoding
parent
63a267f628
commit
56e9bf45fd
|
@ -154,12 +154,13 @@ def test_base64io_decode(bytes_to_generate, bytes_per_round, number_of_rounds, t
|
|||
assert test == plaintext_source[:total_bytes_to_expect]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("encoding", ("ascii", "utf-8"))
|
||||
@pytest.mark.parametrize(
|
||||
"bytes_to_generate, bytes_per_round, number_of_rounds, total_bytes_to_expect", build_test_cases()
|
||||
)
|
||||
def test_base64io_decode_str(bytes_to_generate, bytes_per_round, number_of_rounds, total_bytes_to_expect):
|
||||
def test_base64io_decode_str(encoding, bytes_to_generate, bytes_per_round, number_of_rounds, total_bytes_to_expect):
|
||||
plaintext_source = os.urandom(bytes_to_generate)
|
||||
plaintext_b64 = io.StringIO(base64.b64encode(plaintext_source).decode("ascii"))
|
||||
plaintext_b64 = io.StringIO(base64.b64encode(plaintext_source).decode(encoding))
|
||||
plaintext_wrapped = Base64IO(plaintext_b64)
|
||||
|
||||
test = b""
|
||||
|
@ -313,9 +314,10 @@ def test_base64io_decode_with_whitespace(plaintext_source, b64_plaintext_with_wh
|
|||
assert test == plaintext_source[:read_bytes]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("encoding", ("ascii", "utf-8"))
|
||||
@pytest.mark.parametrize("plaintext_source, b64_plaintext_with_whitespace, read_bytes", build_whitespace_testcases())
|
||||
def test_base64io_decode_with_whitespace_str(plaintext_source, b64_plaintext_with_whitespace, read_bytes):
|
||||
with Base64IO(io.StringIO(b64_plaintext_with_whitespace.decode("ascii"))) as decoder:
|
||||
def test_base64io_decode_with_whitespace_str(encoding, plaintext_source, b64_plaintext_with_whitespace, read_bytes):
|
||||
with Base64IO(io.StringIO(b64_plaintext_with_whitespace.decode(encoding))) as decoder:
|
||||
test = decoder.read(read_bytes)
|
||||
|
||||
assert test == plaintext_source[:read_bytes]
|
||||
|
|
Loading…
Reference in New Issue