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


Python missing_enum_values_pb2.TestEnumValues方法代码示例

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


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

示例1: setUp

# 需要导入模块: from google.protobuf.internal import missing_enum_values_pb2 [as 别名]
# 或者: from google.protobuf.internal.missing_enum_values_pb2 import TestEnumValues [as 别名]
def setUp(self):
    self.descriptor = missing_enum_values_pb2.TestEnumValues.DESCRIPTOR

    self.message = missing_enum_values_pb2.TestEnumValues()
    # TestEnumValues.ZERO = 0, but does not exist in the other NestedEnum.
    self.message.optional_nested_enum = (
        missing_enum_values_pb2.TestEnumValues.ZERO)
    self.message.repeated_nested_enum.extend([
        missing_enum_values_pb2.TestEnumValues.ZERO,
        missing_enum_values_pb2.TestEnumValues.ONE,
        ])
    self.message.packed_nested_enum.extend([
        missing_enum_values_pb2.TestEnumValues.ZERO,
        missing_enum_values_pb2.TestEnumValues.ONE,
        ])
    self.message_data = self.message.SerializeToString()
    self.missing_message = missing_enum_values_pb2.TestMissingEnumValues()
    self.missing_message.ParseFromString(self.message_data)

  # CheckUnknownField() is an additional Pure Python check which checks
  # a detail of unknown fields. It cannot be used by the C++
  # implementation because some protect members are called.
  # The test is added for historical reasons. It is not necessary as
  # serialized string is checked. 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:26,代码来源:unknown_fields_test.py

示例2: setUp

# 需要导入模块: from google.protobuf.internal import missing_enum_values_pb2 [as 别名]
# 或者: from google.protobuf.internal.missing_enum_values_pb2 import TestEnumValues [as 别名]
def setUp(self):
    self.descriptor = missing_enum_values_pb2.TestEnumValues.DESCRIPTOR

    self.message = missing_enum_values_pb2.TestEnumValues()
    # TestEnumValues.ZERO = 0, but does not exist in the other NestedEnum.
    self.message.optional_nested_enum = (
        missing_enum_values_pb2.TestEnumValues.ZERO)
    self.message.repeated_nested_enum.extend([
        missing_enum_values_pb2.TestEnumValues.ZERO,
        missing_enum_values_pb2.TestEnumValues.ONE,
        ])
    self.message.packed_nested_enum.extend([
        missing_enum_values_pb2.TestEnumValues.ZERO,
        missing_enum_values_pb2.TestEnumValues.ONE,
        ])
    self.message_data = self.message.SerializeToString()
    self.missing_message = missing_enum_values_pb2.TestMissingEnumValues()
    self.missing_message.ParseFromString(self.message_data)

  # GetUnknownField() checks a detail of the Python implementation, which stores
  # unknown fields as serialized strings. It cannot be used by the C++
  # implementation: it's enough to check that the message is correctly
  # serialized. 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:25,代码来源:unknown_fields_test.py

示例3: setUp

# 需要导入模块: from google.protobuf.internal import missing_enum_values_pb2 [as 别名]
# 或者: from google.protobuf.internal.missing_enum_values_pb2 import TestEnumValues [as 别名]
def setUp(self):
    self.descriptor = missing_enum_values_pb2.TestEnumValues.DESCRIPTOR

    self.message = missing_enum_values_pb2.TestEnumValues()
    self.message.optional_nested_enum = (
      missing_enum_values_pb2.TestEnumValues.ZERO)
    self.message.repeated_nested_enum.extend([
      missing_enum_values_pb2.TestEnumValues.ZERO,
      missing_enum_values_pb2.TestEnumValues.ONE,
      ])
    self.message.packed_nested_enum.extend([
      missing_enum_values_pb2.TestEnumValues.ZERO,
      missing_enum_values_pb2.TestEnumValues.ONE,
      ])
    self.message_data = self.message.SerializeToString()
    self.missing_message = missing_enum_values_pb2.TestMissingEnumValues()
    self.missing_message.ParseFromString(self.message_data)
    if api_implementation.Type() != 'cpp':
      # _unknown_fields is an implementation detail.
      self.unknown_fields = self.missing_message._unknown_fields

  # All the tests that use GetField() check an implementation detail of the
  # Python implementation, which stores unknown fields as serialized strings.
  # These tests are skipped by the C++ implementation: it's enough to check that
  # the message is correctly serialized. 
开发者ID:sklearn-theano,项目名称:sklearn-theano,代码行数:27,代码来源:unknown_fields_test.py

示例4: setUp

# 需要导入模块: from google.protobuf.internal import missing_enum_values_pb2 [as 别名]
# 或者: from google.protobuf.internal.missing_enum_values_pb2 import TestEnumValues [as 别名]
def setUp(self):
    self.descriptor = missing_enum_values_pb2.TestEnumValues.DESCRIPTOR

    self.message = missing_enum_values_pb2.TestEnumValues()
    self.message.optional_nested_enum = (
      missing_enum_values_pb2.TestEnumValues.ZERO)
    self.message.repeated_nested_enum.extend([
      missing_enum_values_pb2.TestEnumValues.ZERO,
      missing_enum_values_pb2.TestEnumValues.ONE,
      ])
    self.message.packed_nested_enum.extend([
      missing_enum_values_pb2.TestEnumValues.ZERO,
      missing_enum_values_pb2.TestEnumValues.ONE,
      ])
    self.message_data = self.message.SerializeToString()
    self.missing_message = missing_enum_values_pb2.TestMissingEnumValues()
    self.missing_message.ParseFromString(self.message_data)
    self.unknown_fields = self.missing_message._unknown_fields 
开发者ID:katharosada,项目名称:botchallenge,代码行数:20,代码来源:unknown_fields_test.py

示例5: CheckUnknownField

# 需要导入模块: from google.protobuf.internal import missing_enum_values_pb2 [as 别名]
# 或者: from google.protobuf.internal.missing_enum_values_pb2 import TestEnumValues [as 别名]
def CheckUnknownField(self, name, expected_value):
    field_descriptor = self.descriptor.fields_by_name[name]
    wire_type = type_checkers.FIELD_TYPE_TO_WIRE_TYPE[field_descriptor.type]
    field_tag = encoder.TagBytes(field_descriptor.number, wire_type)
    result_dict = {}
    for tag_bytes, value in self.missing_message._unknown_fields:
      if tag_bytes == field_tag:
        decoder = missing_enum_values_pb2.TestEnumValues._decoders_by_tag[
            tag_bytes][0]
        decoder(value, 0, len(value), self.message, result_dict)
    self.assertEqual(expected_value, result_dict[field_descriptor]) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:13,代码来源:unknown_fields_test.py

示例6: testUnknownParseMismatchEnumValue

# 需要导入模块: from google.protobuf.internal import missing_enum_values_pb2 [as 别名]
# 或者: from google.protobuf.internal.missing_enum_values_pb2 import TestEnumValues [as 别名]
def testUnknownParseMismatchEnumValue(self):
    just_string = missing_enum_values_pb2.JustString()
    just_string.dummy = 'blah'

    missing = missing_enum_values_pb2.TestEnumValues()
    # The parse is invalid, storing the string proto into the set of
    # unknown fields.
    missing.ParseFromString(just_string.SerializeToString())

    # Fetching the enum field shouldn't crash, instead returning the
    # default value.
    self.assertEqual(missing.optional_nested_enum, 0) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:14,代码来源:unknown_fields_test.py

示例7: testRoundTrip

# 需要导入模块: from google.protobuf.internal import missing_enum_values_pb2 [as 别名]
# 或者: from google.protobuf.internal.missing_enum_values_pb2 import TestEnumValues [as 别名]
def testRoundTrip(self):
    new_message = missing_enum_values_pb2.TestEnumValues()
    new_message.ParseFromString(self.missing_message.SerializeToString())
    self.assertEqual(self.message, new_message) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:6,代码来源:unknown_fields_test.py

示例8: GetUnknownField

# 需要导入模块: from google.protobuf.internal import missing_enum_values_pb2 [as 别名]
# 或者: from google.protobuf.internal.missing_enum_values_pb2 import TestEnumValues [as 别名]
def GetUnknownField(self, name):
    field_descriptor = self.descriptor.fields_by_name[name]
    wire_type = type_checkers.FIELD_TYPE_TO_WIRE_TYPE[field_descriptor.type]
    field_tag = encoder.TagBytes(field_descriptor.number, wire_type)
    result_dict = {}
    for tag_bytes, value in self.missing_message._unknown_fields:
      if tag_bytes == field_tag:
        decoder = missing_enum_values_pb2.TestEnumValues._decoders_by_tag[
            tag_bytes][0]
        decoder(value, 0, len(value), self.message, result_dict)
    return result_dict[field_descriptor] 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:13,代码来源:unknown_fields_test.py

示例9: GetField

# 需要导入模块: from google.protobuf.internal import missing_enum_values_pb2 [as 别名]
# 或者: from google.protobuf.internal.missing_enum_values_pb2 import TestEnumValues [as 别名]
def GetField(self, name):
    field_descriptor = self.descriptor.fields_by_name[name]
    wire_type = type_checkers.FIELD_TYPE_TO_WIRE_TYPE[field_descriptor.type]
    field_tag = encoder.TagBytes(field_descriptor.number, wire_type)
    result_dict = {}
    for tag_bytes, value in self.unknown_fields:
      if tag_bytes == field_tag:
        decoder = missing_enum_values_pb2.TestEnumValues._decoders_by_tag[
          tag_bytes][0]
        decoder(value, 0, len(value), self.message, result_dict)
    return result_dict[field_descriptor] 
开发者ID:sklearn-theano,项目名称:sklearn-theano,代码行数:13,代码来源:unknown_fields_test.py

示例10: GetField

# 需要导入模块: from google.protobuf.internal import missing_enum_values_pb2 [as 别名]
# 或者: from google.protobuf.internal.missing_enum_values_pb2 import TestEnumValues [as 别名]
def GetField(self, name):
    field_descriptor = self.descriptor.fields_by_name[name]
    wire_type = type_checkers.FIELD_TYPE_TO_WIRE_TYPE[field_descriptor.type]
    field_tag = encoder.TagBytes(field_descriptor.number, wire_type)
    result_dict = {}
    for tag_bytes, value in self.unknown_fields:
      if tag_bytes == field_tag:
        decoder = missing_enum_values_pb2.TestEnumValues._decoders_by_tag[
          tag_bytes]
        decoder(value, 0, len(value), self.message, result_dict)
    return result_dict[field_descriptor] 
开发者ID:katharosada,项目名称:botchallenge,代码行数:13,代码来源:unknown_fields_test.py


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