當前位置: 首頁>>代碼示例>>Python>>正文


Python unittest_import_public_pb2.DESCRIPTOR屬性代碼示例

本文整理匯總了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') 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:20,代碼來源:generator_test.py

示例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) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:19,代碼來源:generator_test.py

示例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) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:19,代碼來源:generator_test.py

示例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) 
開發者ID:katharosada,項目名稱:botchallenge,代碼行數:19,代碼來源:generator_test.py

示例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) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:8,代碼來源:generator_test.py

示例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) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:17,代碼來源:generator_test.py

示例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) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:7,代碼來源:generator_test.py

示例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) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:7,代碼來源:generator_test.py

示例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) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:9,代碼來源:generator_test.py

示例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. 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:8,代碼來源:generator_test.py

示例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, []) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:13,代碼來源:generator_test.py

示例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) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:16,代碼來源:generator_test.py

示例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) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:6,代碼來源:generator_test.py

示例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]) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:13,代碼來源:generator_test.py

示例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) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:13,代碼來源:generator_test.py


注:本文中的google.protobuf.unittest_import_public_pb2.DESCRIPTOR屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。