def test_decoded_text_from_binary_simple(): """A unicode string encoded as bytes object decodes back correctly.""" text = "Hello, world ☺" encoded = text.encode("utf-8") assert _util.decoded_text_from_binary(BytesIO(encoded)) == text
def test_decoded_text_from_binary_size(): """Only a given amount of bytes is decoded.""" text = "Hello, world ☺" encoded = text.encode("utf-8") assert _util.decoded_text_from_binary(BytesIO(encoded), size=5) == "Hello"
def test_decoded_text_from_binary_crlf(): """Given CRLF line endings, convert to LF.""" text = "Hello\r\nworld" encoded = text.encode("utf-8") assert _util.decoded_text_from_binary(BytesIO(encoded)) == "Hello\nworld"