def testCustomClassSerialization(self): my_custom = MyCustomClass(1234, "my_name") serialized = serialization.serialize(my_custom) self.assertTrue( serialized.representation.Is( serialization_test_pb2.MyCustomRepresentation.DESCRIPTOR)) proto = serialization_test_pb2.MyCustomRepresentation() serialized.representation.Unpack(proto) self.assertEqual(proto.index, my_custom.index) self.assertEqual(proto.name, my_custom.name)
def experimental_as_proto(self): return serialization_test_pb2.MyCustomRepresentation()
def experimental_as_proto(self): proto = serialization_test_pb2.MyCustomRepresentation(index=self.index, name=self.name) return proto
def to_proto(self): return serialization_test_pb2.MyCustomRepresentation()