当前位置: 首页>>代码示例>>Python>>正文


Python test_util.SetAllPackedFields方法代码示例

本文整理汇总了Python中google.protobuf.internal.test_util.SetAllPackedFields方法的典型用法代码示例。如果您正苦于以下问题:Python test_util.SetAllPackedFields方法的具体用法?Python test_util.SetAllPackedFields怎么用?Python test_util.SetAllPackedFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在google.protobuf.internal.test_util的用法示例。


在下文中一共展示了test_util.SetAllPackedFields方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testSerializeAllPackedFields

# 需要导入模块: from google.protobuf.internal import test_util [as 别名]
# 或者: from google.protobuf.internal.test_util import SetAllPackedFields [as 别名]
def testSerializeAllPackedFields(self):
    first_proto = unittest_pb2.TestPackedTypes()
    second_proto = unittest_pb2.TestPackedTypes()
    test_util.SetAllPackedFields(first_proto)
    serialized = first_proto.SerializeToString()
    self.assertEqual(first_proto.ByteSize(), len(serialized))
    bytes_read = second_proto.MergeFromString(serialized)
    self.assertEqual(second_proto.ByteSize(), bytes_read)
    self.assertEqual(first_proto, second_proto) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:11,代码来源:reflection_test.py

示例2: testParsePackedFromUnpacked

# 需要导入模块: from google.protobuf.internal import test_util [as 别名]
# 或者: from google.protobuf.internal.test_util import SetAllPackedFields [as 别名]
def testParsePackedFromUnpacked(self):
    unpacked = unittest_pb2.TestUnpackedTypes()
    test_util.SetAllUnpackedFields(unpacked)
    packed = unittest_pb2.TestPackedTypes()
    serialized = unpacked.SerializeToString()
    self.assertEqual(
        len(serialized),
        packed.MergeFromString(serialized))
    expected = unittest_pb2.TestPackedTypes()
    test_util.SetAllPackedFields(expected)
    self.assertEqual(expected, packed) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:13,代码来源:reflection_test.py

示例3: testParseUnpackedFromPacked

# 需要导入模块: from google.protobuf.internal import test_util [as 别名]
# 或者: from google.protobuf.internal.test_util import SetAllPackedFields [as 别名]
def testParseUnpackedFromPacked(self):
    packed = unittest_pb2.TestPackedTypes()
    test_util.SetAllPackedFields(packed)
    unpacked = unittest_pb2.TestUnpackedTypes()
    serialized = packed.SerializeToString()
    self.assertEqual(
        len(serialized),
        unpacked.MergeFromString(serialized))
    expected = unittest_pb2.TestUnpackedTypes()
    test_util.SetAllUnpackedFields(expected)
    self.assertEqual(expected, unpacked) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:13,代码来源:reflection_test.py

示例4: testGoldenPackedMessage

# 需要导入模块: from google.protobuf.internal import test_util [as 别名]
# 或者: from google.protobuf.internal.test_util import SetAllPackedFields [as 别名]
def testGoldenPackedMessage(self, message_module):
    golden_data = test_util.GoldenFileData('golden_packed_fields_message')
    golden_message = message_module.TestPackedTypes()
    golden_message.ParseFromString(golden_data)
    all_set = message_module.TestPackedTypes()
    test_util.SetAllPackedFields(all_set)
    self.assertEqual(all_set, golden_message)
    self.assertEqual(golden_data, all_set.SerializeToString())
    golden_copy = copy.deepcopy(golden_message)
    self.assertEqual(golden_data, golden_copy.SerializeToString()) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:12,代码来源:message_test.py

示例5: testGoldenPackedMessage

# 需要导入模块: from google.protobuf.internal import test_util [as 别名]
# 或者: from google.protobuf.internal.test_util import SetAllPackedFields [as 别名]
def testGoldenPackedMessage(self):
    golden_data = test_util.GoldenFileData('golden_packed_fields_message')
    golden_message = unittest_pb2.TestPackedTypes()
    golden_message.ParseFromString(golden_data)
    all_set = unittest_pb2.TestPackedTypes()
    test_util.SetAllPackedFields(all_set)
    self.assertEquals(all_set, golden_message)
    self.assertEqual(golden_data, all_set.SerializeToString())
    golden_copy = copy.deepcopy(golden_message)
    self.assertEqual(golden_data, golden_copy.SerializeToString()) 
开发者ID:katharosada,项目名称:botchallenge,代码行数:12,代码来源:message_test.py

示例6: testGoldenPackedMessage

# 需要导入模块: from google.protobuf.internal import test_util [as 别名]
# 或者: from google.protobuf.internal.test_util import SetAllPackedFields [as 别名]
def testGoldenPackedMessage(self):
    golden_data = test_util.GoldenFile('golden_packed_fields_message').read()
    golden_message = unittest_pb2.TestPackedTypes()
    golden_message.ParseFromString(golden_data)
    all_set = unittest_pb2.TestPackedTypes()
    test_util.SetAllPackedFields(all_set)
    self.assertEquals(all_set, golden_message)
    self.assertEqual(golden_data, all_set.SerializeToString())
    golden_copy = copy.deepcopy(golden_message)
    self.assertEqual(golden_data, golden_copy.SerializeToString()) 
开发者ID:apple,项目名称:coremltools,代码行数:12,代码来源:message_test.py


注:本文中的google.protobuf.internal.test_util.SetAllPackedFields方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。