def as_utf8(s): """ Function to decode an input with the UTF-8 codec, or return as-is. Parameters ---------- s : object Returns ------- output If the input was of type `bytes`, the return value is a `str` decoded with the UTF-8 codec. Otherwise, the return value is identically the input. See Also -------- decoder """ return utils.do_decoding(s, "utf-8")
def test_do_decoding_decodes_bytes_string_to_unicode(): assert type(utils.do_decoding(b"bytes", "ascii")) is py23_str assert utils.do_decoding(b"bytes", "ascii") == "bytes" assert utils.do_decoding(b"bytes", "ascii") == b"bytes".decode("ascii")