def test_encode_decode_invalid_utf8(): data = b"\xc3\x00" # invalid utf-8 result = types.encode(types.decode(data)) assert isinstance(result, str) assert result == data.decode(errors="surrogateescape")
def serialize(self, value, display=False): if value is None: return "" value = f"{value.event},{value.active},{value.bouncetime}" return types.encode(value)
def test_encode(value, expected): assert types.encode(value) == expected
def serialize(self, value, display=False): if value is None: return "" options = ",".join({f"{k}={v}" for k, v in value.options.items()}) value = f"{value.event},{value.active},{value.bouncetime},{options}" return types.encode(value)