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


Python unittest_import_pb2.DESCRIPTOR属性代码示例

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


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

示例1: testPackage

# 需要导入模块: from google.protobuf import unittest_import_pb2 [as 别名]
# 或者: from google.protobuf.unittest_import_pb2 import DESCRIPTOR [as 别名]
def testPackage(self):
    self.assertEqual(
        unittest_pb2.TestAllTypes.DESCRIPTOR.file.package,
        'protobuf_unittest')
    desc = unittest_pb2.TestAllTypes.NestedMessage.DESCRIPTOR
    self.assertEqual(desc.file.package, 'protobuf_unittest')
    self.assertEqual(
        unittest_import_pb2.ImportMessage.DESCRIPTOR.file.package,
        'protobuf_unittest_import')

    self.assertEqual(
        unittest_pb2._FOREIGNENUM.file.package, 'protobuf_unittest')
    self.assertEqual(
        unittest_pb2._TESTALLTYPES_NESTEDENUM.file.package,
        'protobuf_unittest')
    self.assertEqual(
        unittest_import_pb2._IMPORTENUM.file.package,
        'protobuf_unittest_import') 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:20,代码来源:generator_test.py

示例2: testOneof

# 需要导入模块: from google.protobuf import unittest_import_pb2 [as 别名]
# 或者: from google.protobuf.unittest_import_pb2 import DESCRIPTOR [as 别名]
def testOneof(self):
    desc = unittest_pb2.TestAllTypes.DESCRIPTOR
    self.assertEqual(1, len(desc.oneofs))
    self.assertEqual('oneof_field', desc.oneofs[0].name)
    self.assertEqual(0, desc.oneofs[0].index)
    self.assertIs(desc, desc.oneofs[0].containing_type)
    self.assertIs(desc.oneofs[0], desc.oneofs_by_name['oneof_field'])
    nested_names = set(['oneof_uint32', 'oneof_nested_message',
                        'oneof_string', 'oneof_bytes'])
    self.assertEqual(
        nested_names,
        set([field.name for field in desc.oneofs[0].fields]))
    for field_name, field_desc in list(desc.fields_by_name.items()):
      if field_name in nested_names:
        self.assertIs(desc.oneofs[0], field_desc.containing_oneof)
      else:
        self.assertIsNone(field_desc.containing_oneof) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:19,代码来源:generator_test.py

示例3: testNestedOptions

# 需要导入模块: from google.protobuf import unittest_import_pb2 [as 别名]
# 或者: from google.protobuf.unittest_import_pb2 import DESCRIPTOR [as 别名]
def testNestedOptions(self):
    nested_message =\
        unittest_custom_options_pb2.NestedOptionType.NestedMessage.DESCRIPTOR
    self.assertEqual(1001, nested_message.GetOptions().Extensions[
        unittest_custom_options_pb2.message_opt1])
    nested_field = nested_message.fields_by_name["nested_field"]
    self.assertEqual(1002, nested_field.GetOptions().Extensions[
        unittest_custom_options_pb2.field_opt1])
    outer_message =\
        unittest_custom_options_pb2.NestedOptionType.DESCRIPTOR
    nested_enum = outer_message.enum_types_by_name["NestedEnum"]
    self.assertEqual(1003, nested_enum.GetOptions().Extensions[
        unittest_custom_options_pb2.enum_opt1])
    nested_enum_value = outer_message.enum_values_by_name["NESTED_ENUM_VALUE"]
    self.assertEqual(1004, nested_enum_value.GetOptions().Extensions[
        unittest_custom_options_pb2.enum_value_opt1])
    nested_extension = outer_message.extensions_by_name["nested_extension"]
    self.assertEqual(1005, nested_extension.GetOptions().Extensions[
        unittest_custom_options_pb2.field_opt2]) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:21,代码来源:descriptor_test.py

示例4: testDescriptor

# 需要导入模块: from google.protobuf import unittest_import_pb2 [as 别名]
# 或者: from google.protobuf.unittest_import_pb2 import DESCRIPTOR [as 别名]
def testDescriptor(self):
    message_descriptor = unittest_pb2.TestAllTypes.DESCRIPTOR
    self.CheckMessageDescriptor(message_descriptor)
    field_descriptor = message_descriptor.fields_by_name['optional_int32']
    self.CheckFieldDescriptor(field_descriptor)
    field_descriptor = message_descriptor.fields_by_camelcase_name[
        'optionalInt32']
    self.CheckFieldDescriptor(field_descriptor)
    enum_descriptor = unittest_pb2.DESCRIPTOR.enum_types_by_name[
        'ForeignEnum']
    self.assertEqual(None, enum_descriptor.containing_type)
    # Test extension range
    self.assertEqual(
        unittest_pb2.TestAllExtensions.DESCRIPTOR.extension_ranges,
        [(1, 536870912)])
    self.assertEqual(
        unittest_pb2.TestMultipleExtensionRanges.DESCRIPTOR.extension_ranges,
        [(42, 43), (4143, 4244), (65536, 536870912)]) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:20,代码来源:descriptor_test.py

示例5: testCopyToProto_ForeignNestedMessage

# 需要导入模块: from google.protobuf import unittest_import_pb2 [as 别名]
# 或者: from google.protobuf.unittest_import_pb2 import DESCRIPTOR [as 别名]
def testCopyToProto_ForeignNestedMessage(self):
    TEST_FOREIGN_NESTED_ASCII = """
      name: 'TestForeignNested'
      field: <
        name: 'foreign_nested'
        number: 1
        label: 1  # Optional
        type: 11  # TYPE_MESSAGE
        type_name: '.protobuf_unittest.TestAllTypes.NestedMessage'
      >
      """

    self._InternalTestCopyToProto(
        unittest_pb2.TestForeignNested.DESCRIPTOR,
        descriptor_pb2.DescriptorProto,
        TEST_FOREIGN_NESTED_ASCII) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:18,代码来源:descriptor_test.py

示例6: testCopyToProto_ForeignEnum

# 需要导入模块: from google.protobuf import unittest_import_pb2 [as 别名]
# 或者: from google.protobuf.unittest_import_pb2 import DESCRIPTOR [as 别名]
def testCopyToProto_ForeignEnum(self):
    TEST_FOREIGN_ENUM_ASCII = """
      name: 'ForeignEnum'
      value: <
        name: 'FOREIGN_FOO'
        number: 4
      >
      value: <
        name: 'FOREIGN_BAR'
        number: 5
      >
      value: <
        name: 'FOREIGN_BAZ'
        number: 6
      >
      """

    self._InternalTestCopyToProto(
        unittest_pb2.ForeignEnum.DESCRIPTOR,
        descriptor_pb2.EnumDescriptorProto,
        TEST_FOREIGN_ENUM_ASCII) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:23,代码来源:descriptor_test.py

示例7: testCopyToProto_SeveralExtensions

# 需要导入模块: from google.protobuf import unittest_import_pb2 [as 别名]
# 或者: from google.protobuf.unittest_import_pb2 import DESCRIPTOR [as 别名]
def testCopyToProto_SeveralExtensions(self):
    TEST_MESSAGE_WITH_SEVERAL_EXTENSIONS_ASCII = """
      name: 'TestMultipleExtensionRanges'
      extension_range: <
        start: 42
        end: 43
      >
      extension_range: <
        start: 4143
        end: 4244
      >
      extension_range: <
        start: 65536
        end: 536870912
      >
      """

    self._InternalTestCopyToProto(
        unittest_pb2.TestMultipleExtensionRanges.DESCRIPTOR,
        descriptor_pb2.DescriptorProto,
        TEST_MESSAGE_WITH_SEVERAL_EXTENSIONS_ASCII) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:23,代码来源:descriptor_test.py

示例8: testCopyToProto_ServiceDescriptor

# 需要导入模块: from google.protobuf import unittest_import_pb2 [as 别名]
# 或者: from google.protobuf.unittest_import_pb2 import DESCRIPTOR [as 别名]
def testCopyToProto_ServiceDescriptor(self):
    TEST_SERVICE_ASCII = """
      name: 'TestService'
      method: <
        name: 'Foo'
        input_type: '.protobuf_unittest.FooRequest'
        output_type: '.protobuf_unittest.FooResponse'
      >
      method: <
        name: 'Bar'
        input_type: '.protobuf_unittest.BarRequest'
        output_type: '.protobuf_unittest.BarResponse'
      >
      """
    self._InternalTestCopyToProto(
        unittest_pb2.TestService.DESCRIPTOR,
        descriptor_pb2.ServiceDescriptorProto,
        TEST_SERVICE_ASCII) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:20,代码来源:descriptor_test.py

示例9: testOneof

# 需要导入模块: from google.protobuf import unittest_import_pb2 [as 别名]
# 或者: from google.protobuf.unittest_import_pb2 import DESCRIPTOR [as 别名]
def testOneof(self):
    desc = unittest_pb2.TestAllTypes.DESCRIPTOR
    self.assertEqual(1, len(desc.oneofs))
    self.assertEqual('oneof_field', desc.oneofs[0].name)
    self.assertEqual(0, desc.oneofs[0].index)
    self.assertIs(desc, desc.oneofs[0].containing_type)
    self.assertIs(desc.oneofs[0], desc.oneofs_by_name['oneof_field'])
    nested_names = set(['oneof_uint32', 'oneof_nested_message',
                        'oneof_string', 'oneof_bytes'])
    self.assertEqual(
        nested_names,
        set([field.name for field in desc.oneofs[0].fields]))
    for field_name, field_desc in desc.fields_by_name.items():
      if field_name in nested_names:
        self.assertIs(desc.oneofs[0], field_desc.containing_oneof)
      else:
        self.assertIsNone(field_desc.containing_oneof) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:19,代码来源:generator_test.py

示例10: testCopyToProto_Options

# 需要导入模块: from google.protobuf import unittest_import_pb2 [as 别名]
# 或者: from google.protobuf.unittest_import_pb2 import DESCRIPTOR [as 别名]
def testCopyToProto_Options(self):
    TEST_DEPRECATED_FIELDS_ASCII = """
      name: 'TestDeprecatedFields'
      field: <
        name: 'deprecated_int32'
        number: 1
        label: 1  # Optional
        type: 5  # TYPE_INT32
        options: <
          deprecated: true
        >
      >
      """

    self._InternalTestCopyToProto(
        unittest_pb2.TestDeprecatedFields.DESCRIPTOR,
        descriptor_pb2.DescriptorProto,
        TEST_DEPRECATED_FIELDS_ASCII) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:20,代码来源:descriptor_test.py

示例11: testCopyToProto_ServiceDescriptor

# 需要导入模块: from google.protobuf import unittest_import_pb2 [as 别名]
# 或者: from google.protobuf.unittest_import_pb2 import DESCRIPTOR [as 别名]
def testCopyToProto_ServiceDescriptor(self):
    TEST_SERVICE_ASCII = """
      name: 'TestService'
      method: <
        name: 'Foo'
        input_type: '.protobuf_unittest.FooRequest'
        output_type: '.protobuf_unittest.FooResponse'
      >
      method: <
        name: 'Bar'
        input_type: '.protobuf_unittest.BarRequest'
        output_type: '.protobuf_unittest.BarResponse'
      >
      """
    # TODO(rocking): enable this test after the proto descriptor change is
    # checked in.
    #self._InternalTestCopyToProto(
    #    unittest_pb2.TestService.DESCRIPTOR,
    #    descriptor_pb2.ServiceDescriptorProto,
    #    TEST_SERVICE_ASCII) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:22,代码来源:descriptor_test.py

示例12: testNestedMessageDescriptor

# 需要导入模块: from google.protobuf import unittest_import_pb2 [as 别名]
# 或者: from google.protobuf.unittest_import_pb2 import DESCRIPTOR [as 别名]
def testNestedMessageDescriptor(self):
    field_name = 'optional_nested_message'
    proto_type = unittest_pb2.TestAllTypes
    self.assertEqual(
        proto_type.NestedMessage.DESCRIPTOR,
        proto_type.DESCRIPTOR.fields_by_name[field_name].message_type) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:8,代码来源:generator_test.py

示例13: testHasDefaultValues

# 需要导入模块: from google.protobuf import unittest_import_pb2 [as 别名]
# 或者: from google.protobuf.unittest_import_pb2 import DESCRIPTOR [as 别名]
def testHasDefaultValues(self):
    desc = unittest_pb2.TestAllTypes.DESCRIPTOR

    expected_has_default_by_name = {
        'optional_int32': False,
        'repeated_int32': False,
        'optional_nested_message': False,
        'default_int32': True,
    }

    has_default_by_name = dict(
        [(f.name, f.has_default_value)
         for f in desc.fields
         if f.name in expected_has_default_by_name])
    self.assertEqual(expected_has_default_by_name, has_default_by_name) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:17,代码来源:generator_test.py

示例14: testContainingTypeBehaviorForExtensions

# 需要导入模块: from google.protobuf import unittest_import_pb2 [as 别名]
# 或者: from google.protobuf.unittest_import_pb2 import DESCRIPTOR [as 别名]
def testContainingTypeBehaviorForExtensions(self):
    self.assertEqual(unittest_pb2.optional_int32_extension.containing_type,
                     unittest_pb2.TestAllExtensions.DESCRIPTOR)
    self.assertEqual(unittest_pb2.TestRequired.single.containing_type,
                     unittest_pb2.TestAllExtensions.DESCRIPTOR) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:7,代码来源:generator_test.py

示例15: testExtensionScope

# 需要导入模块: from google.protobuf import unittest_import_pb2 [as 别名]
# 或者: from google.protobuf.unittest_import_pb2 import DESCRIPTOR [as 别名]
def testExtensionScope(self):
    self.assertEqual(unittest_pb2.optional_int32_extension.extension_scope,
                     None)
    self.assertEqual(unittest_pb2.TestRequired.single.extension_scope,
                     unittest_pb2.TestRequired.DESCRIPTOR) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:7,代码来源:generator_test.py


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