def test_string_decode_encode(self): from klvdata.common import bytes_to_str from klvdata.common import str_to_bytes self.assertEqual( str_to_bytes(bytes_to_str(b'\x50\x72\x65\x64\x61\x74\x6F\x72')), b'\x50\x72\x65\x64\x61\x74\x6F\x72')
def __init__(self, value): try: self.value = bytes_to_str(value) except TypeError: self.value = value