本文整理汇总了Python中google.protobuf.unittest_import_public_pb2.DESCRIPTOR属性的典型用法代码示例。如果您正苦于以下问题:Python unittest_import_public_pb2.DESCRIPTOR属性的具体用法?Python unittest_import_public_pb2.DESCRIPTOR怎么用?Python unittest_import_public_pb2.DESCRIPTOR使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类google.protobuf.unittest_import_public_pb2
的用法示例。
在下文中一共展示了unittest_import_public_pb2.DESCRIPTOR属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testPackage
# 需要导入模块: from google.protobuf import unittest_import_public_pb2 [as 别名]
# 或者: from google.protobuf.unittest_import_public_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')
示例2: testOneof
# 需要导入模块: from google.protobuf import unittest_import_public_pb2 [as 别名]
# 或者: from google.protobuf.unittest_import_public_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)
示例3: testOneof
# 需要导入模块: from google.protobuf import unittest_import_public_pb2 [as 别名]
# 或者: from google.protobuf.unittest_import_public_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)
示例4: testOneof
# 需要导入模块: from google.protobuf import unittest_import_public_pb2 [as 别名]
# 或者: from google.protobuf.unittest_import_public_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.assertSameElements(
nested_names,
[field.name for field in desc.oneofs[0].fields])
for field_name, field_desc in desc.fields_by_name.iteritems():
if field_name in nested_names:
self.assertIs(desc.oneofs[0], field_desc.containing_oneof)
else:
self.assertIsNone(field_desc.containing_oneof)
示例5: testNestedMessageDescriptor
# 需要导入模块: from google.protobuf import unittest_import_public_pb2 [as 别名]
# 或者: from google.protobuf.unittest_import_public_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)
示例6: testHasDefaultValues
# 需要导入模块: from google.protobuf import unittest_import_public_pb2 [as 别名]
# 或者: from google.protobuf.unittest_import_public_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)
示例7: testContainingTypeBehaviorForExtensions
# 需要导入模块: from google.protobuf import unittest_import_public_pb2 [as 别名]
# 或者: from google.protobuf.unittest_import_public_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)
示例8: testExtensionScope
# 需要导入模块: from google.protobuf import unittest_import_public_pb2 [as 别名]
# 或者: from google.protobuf.unittest_import_public_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)
示例9: testIsExtension
# 需要导入模块: from google.protobuf import unittest_import_public_pb2 [as 别名]
# 或者: from google.protobuf.unittest_import_public_pb2 import DESCRIPTOR [as 别名]
def testIsExtension(self):
self.assertTrue(unittest_pb2.optional_int32_extension.is_extension)
self.assertTrue(unittest_pb2.TestRequired.single.is_extension)
message_descriptor = unittest_pb2.TestRequired.DESCRIPTOR
non_extension_descriptor = message_descriptor.fields_by_name['a']
self.assertTrue(not non_extension_descriptor.is_extension)
示例10: testMessageWithCustomOptions
# 需要导入模块: from google.protobuf import unittest_import_public_pb2 [as 别名]
# 或者: from google.protobuf.unittest_import_public_pb2 import DESCRIPTOR [as 别名]
def testMessageWithCustomOptions(self):
proto = unittest_custom_options_pb2.TestMessageWithCustomOptions()
enum_options = proto.DESCRIPTOR.enum_types_by_name['AnEnum'].GetOptions()
self.assertTrue(enum_options is not None)
# TODO(gps): We really should test for the presence of the enum_opt1
# extension and for its value to be set to -789.
示例11: testNestedTypes
# 需要导入模块: from google.protobuf import unittest_import_public_pb2 [as 别名]
# 或者: from google.protobuf.unittest_import_public_pb2 import DESCRIPTOR [as 别名]
def testNestedTypes(self):
self.assertEqual(
set(unittest_pb2.TestAllTypes.DESCRIPTOR.nested_types),
set([
unittest_pb2.TestAllTypes.NestedMessage.DESCRIPTOR,
unittest_pb2.TestAllTypes.OptionalGroup.DESCRIPTOR,
unittest_pb2.TestAllTypes.RepeatedGroup.DESCRIPTOR,
]))
self.assertEqual(unittest_pb2.TestEmptyMessage.DESCRIPTOR.nested_types, [])
self.assertEqual(
unittest_pb2.TestAllTypes.NestedMessage.DESCRIPTOR.nested_types, [])
示例12: testContainingType
# 需要导入模块: from google.protobuf import unittest_import_public_pb2 [as 别名]
# 或者: from google.protobuf.unittest_import_public_pb2 import DESCRIPTOR [as 别名]
def testContainingType(self):
self.assertTrue(
unittest_pb2.TestEmptyMessage.DESCRIPTOR.containing_type is None)
self.assertTrue(
unittest_pb2.TestAllTypes.DESCRIPTOR.containing_type is None)
self.assertEqual(
unittest_pb2.TestAllTypes.NestedMessage.DESCRIPTOR.containing_type,
unittest_pb2.TestAllTypes.DESCRIPTOR)
self.assertEqual(
unittest_pb2.TestAllTypes.NestedMessage.DESCRIPTOR.containing_type,
unittest_pb2.TestAllTypes.DESCRIPTOR)
self.assertEqual(
unittest_pb2.TestAllTypes.RepeatedGroup.DESCRIPTOR.containing_type,
unittest_pb2.TestAllTypes.DESCRIPTOR)
示例13: testContainingTypeInEnumDescriptor
# 需要导入模块: from google.protobuf import unittest_import_public_pb2 [as 别名]
# 或者: from google.protobuf.unittest_import_public_pb2 import DESCRIPTOR [as 别名]
def testContainingTypeInEnumDescriptor(self):
self.assertTrue(unittest_pb2._FOREIGNENUM.containing_type is None)
self.assertEqual(unittest_pb2._TESTALLTYPES_NESTEDENUM.containing_type,
unittest_pb2.TestAllTypes.DESCRIPTOR)
示例14: testFileDescriptor
# 需要导入模块: from google.protobuf import unittest_import_public_pb2 [as 别名]
# 或者: from google.protobuf.unittest_import_public_pb2 import DESCRIPTOR [as 别名]
def testFileDescriptor(self):
self.assertEqual(unittest_pb2.DESCRIPTOR.name,
'google/protobuf/unittest.proto')
self.assertEqual(unittest_pb2.DESCRIPTOR.package, 'protobuf_unittest')
self.assertFalse(unittest_pb2.DESCRIPTOR.serialized_pb is None)
self.assertEqual(unittest_pb2.DESCRIPTOR.dependencies,
[unittest_import_pb2.DESCRIPTOR])
self.assertEqual(unittest_import_pb2.DESCRIPTOR.dependencies,
[unittest_import_public_pb2.DESCRIPTOR])
self.assertEqual(unittest_import_pb2.DESCRIPTOR.public_dependencies,
[unittest_import_public_pb2.DESCRIPTOR])
示例15: testMessageTypesByName
# 需要导入模块: from google.protobuf import unittest_import_public_pb2 [as 别名]
# 或者: from google.protobuf.unittest_import_public_pb2 import DESCRIPTOR [as 别名]
def testMessageTypesByName(self):
file_type = unittest_pb2.DESCRIPTOR
self.assertEqual(
unittest_pb2._TESTALLTYPES,
file_type.message_types_by_name[unittest_pb2._TESTALLTYPES.name])
# Nested messages shouldn't be included in the message_types_by_name
# dictionary (like in the C++ API).
self.assertFalse(
unittest_pb2._TESTALLTYPES_NESTEDMESSAGE.name in
file_type.message_types_by_name)