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


Python unittest_mset_pb2.TestMessageSetContainer方法代码示例

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


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

示例1: testPrintMessageSet

# 需要导入模块: from google.protobuf import unittest_mset_pb2 [as 别名]
# 或者: from google.protobuf.unittest_mset_pb2 import TestMessageSetContainer [as 别名]
def testPrintMessageSet(self):
    message = unittest_mset_pb2.TestMessageSetContainer()
    ext1 = unittest_mset_pb2.TestMessageSetExtension1.message_set_extension
    ext2 = unittest_mset_pb2.TestMessageSetExtension2.message_set_extension
    message.message_set.Extensions[ext1].i = 23
    message.message_set.Extensions[ext2].str = 'foo'
    self.CompareToGoldenText(
        text_format.MessageToString(message), 'message_set {\n'
        '  [protobuf_unittest.TestMessageSetExtension1] {\n'
        '    i: 23\n'
        '  }\n'
        '  [protobuf_unittest.TestMessageSetExtension2] {\n'
        '    str: \"foo\"\n'
        '  }\n'
        '}\n')

    message = message_set_extensions_pb2.TestMessageSet()
    ext = message_set_extensions_pb2.message_set_extension3
    message.Extensions[ext].text = 'bar'
    self.CompareToGoldenText(
        text_format.MessageToString(message),
        '[google.protobuf.internal.TestMessageSetExtension3] {\n'
        '  text: \"bar\"\n'
        '}\n') 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:26,代码来源:text_format_test.py

示例2: testPrintMessageSetByFieldNumber

# 需要导入模块: from google.protobuf import unittest_mset_pb2 [as 别名]
# 或者: from google.protobuf.unittest_mset_pb2 import TestMessageSetContainer [as 别名]
def testPrintMessageSetByFieldNumber(self):
    out = text_format.TextWriter(False)
    message = unittest_mset_pb2.TestMessageSetContainer()
    ext1 = unittest_mset_pb2.TestMessageSetExtension1.message_set_extension
    ext2 = unittest_mset_pb2.TestMessageSetExtension2.message_set_extension
    message.message_set.Extensions[ext1].i = 23
    message.message_set.Extensions[ext2].str = 'foo'
    text_format.PrintMessage(message, out, use_field_number=True)
    self.CompareToGoldenText(out.getvalue(), '1 {\n'
                             '  1545008 {\n'
                             '    15: 23\n'
                             '  }\n'
                             '  1547769 {\n'
                             '    25: \"foo\"\n'
                             '  }\n'
                             '}\n')
    out.close() 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:19,代码来源:text_format_test.py

示例3: testPrintMessageSetAsOneLine

# 需要导入模块: from google.protobuf import unittest_mset_pb2 [as 别名]
# 或者: from google.protobuf.unittest_mset_pb2 import TestMessageSetContainer [as 别名]
def testPrintMessageSetAsOneLine(self):
    message = unittest_mset_pb2.TestMessageSetContainer()
    ext1 = unittest_mset_pb2.TestMessageSetExtension1.message_set_extension
    ext2 = unittest_mset_pb2.TestMessageSetExtension2.message_set_extension
    message.message_set.Extensions[ext1].i = 23
    message.message_set.Extensions[ext2].str = 'foo'
    self.CompareToGoldenText(
        text_format.MessageToString(message, as_one_line=True),
        'message_set {'
        ' [protobuf_unittest.TestMessageSetExtension1] {'
        ' i: 23'
        ' }'
        ' [protobuf_unittest.TestMessageSetExtension2] {'
        ' str: \"foo\"'
        ' }'
        ' }') 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:18,代码来源:text_format_test.py

示例4: testParseMessageSet

# 需要导入模块: from google.protobuf import unittest_mset_pb2 [as 别名]
# 或者: from google.protobuf.unittest_mset_pb2 import TestMessageSetContainer [as 别名]
def testParseMessageSet(self):
    message = unittest_pb2.TestAllTypes()
    text = ('repeated_uint64: 1\n' 'repeated_uint64: 2\n')
    text_format.Parse(text, message)
    self.assertEqual(1, message.repeated_uint64[0])
    self.assertEqual(2, message.repeated_uint64[1])

    message = unittest_mset_pb2.TestMessageSetContainer()
    text = ('message_set {\n'
            '  [protobuf_unittest.TestMessageSetExtension1] {\n'
            '    i: 23\n'
            '  }\n'
            '  [protobuf_unittest.TestMessageSetExtension2] {\n'
            '    str: \"foo\"\n'
            '  }\n'
            '}\n')
    text_format.Parse(text, message)
    ext1 = unittest_mset_pb2.TestMessageSetExtension1.message_set_extension
    ext2 = unittest_mset_pb2.TestMessageSetExtension2.message_set_extension
    self.assertEqual(23, message.message_set.Extensions[ext1].i)
    self.assertEqual('foo', message.message_set.Extensions[ext2].str) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:23,代码来源:text_format_test.py

示例5: testExtensionSerializationDictMatchesProto3Spec

# 需要导入模块: from google.protobuf import unittest_mset_pb2 [as 别名]
# 或者: from google.protobuf.unittest_mset_pb2 import TestMessageSetContainer [as 别名]
def testExtensionSerializationDictMatchesProto3Spec(self):
    """See go/proto3-json-spec for spec.
    """
    message = unittest_mset_pb2.TestMessageSetContainer()
    ext1 = unittest_mset_pb2.TestMessageSetExtension1.message_set_extension
    ext2 = unittest_mset_pb2.TestMessageSetExtension2.message_set_extension
    message.message_set.Extensions[ext1].i = 23
    message.message_set.Extensions[ext2].str = 'foo'
    message_dict = json_format.MessageToDict(
        message
    )
    golden_dict = {
        'messageSet': {
            '[protobuf_unittest.'
            'TestMessageSetExtension1.messageSetExtension]': {
                'i': 23,
            },
            '[protobuf_unittest.'
            'TestMessageSetExtension2.messageSetExtension]': {
                'str': 'foo',
            },
        },
    }
    self.assertEqual(golden_dict, message_dict) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:26,代码来源:json_format_test.py

示例6: testExtensionSerializationJsonMatchesProto3Spec

# 需要导入模块: from google.protobuf import unittest_mset_pb2 [as 别名]
# 或者: from google.protobuf.unittest_mset_pb2 import TestMessageSetContainer [as 别名]
def testExtensionSerializationJsonMatchesProto3Spec(self):
    """See go/proto3-json-spec for spec.
    """
    message = unittest_mset_pb2.TestMessageSetContainer()
    ext1 = unittest_mset_pb2.TestMessageSetExtension1.message_set_extension
    ext2 = unittest_mset_pb2.TestMessageSetExtension2.message_set_extension
    message.message_set.Extensions[ext1].i = 23
    message.message_set.Extensions[ext2].str = 'foo'
    message_text = json_format.MessageToJson(
        message
    )
    ext1_text = ('protobuf_unittest.TestMessageSetExtension1.'
                 'messageSetExtension')
    ext2_text = ('protobuf_unittest.TestMessageSetExtension2.'
                 'messageSetExtension')
    golden_text = ('{"messageSet": {'
                   '    "[%s]": {'
                   '        "i": 23'
                   '    },'
                   '    "[%s]": {'
                   '        "str": "foo"'
                   '    }'
                   '}}') % (ext1_text, ext2_text)
    self.assertEqual(json.loads(golden_text), json.loads(message_text)) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:26,代码来源:json_format_test.py

示例7: testPrintMessageSet

# 需要导入模块: from google.protobuf import unittest_mset_pb2 [as 别名]
# 或者: from google.protobuf.unittest_mset_pb2 import TestMessageSetContainer [as 别名]
def testPrintMessageSet(self):
    message = unittest_mset_pb2.TestMessageSetContainer()
    ext1 = unittest_mset_pb2.TestMessageSetExtension1.message_set_extension
    ext2 = unittest_mset_pb2.TestMessageSetExtension2.message_set_extension
    message.message_set.Extensions[ext1].i = 23
    message.message_set.Extensions[ext2].str = 'foo'
    self.CompareToGoldenText(
        text_format.MessageToString(message),
        'message_set {\n'
        '  [protobuf_unittest.TestMessageSetExtension1] {\n'
        '    i: 23\n'
        '  }\n'
        '  [protobuf_unittest.TestMessageSetExtension2] {\n'
        '    str: \"foo\"\n'
        '  }\n'
        '}\n') 
开发者ID:sklearn-theano,项目名称:sklearn-theano,代码行数:18,代码来源:text_format_test.py

示例8: testParseMessageSet

# 需要导入模块: from google.protobuf import unittest_mset_pb2 [as 别名]
# 或者: from google.protobuf.unittest_mset_pb2 import TestMessageSetContainer [as 别名]
def testParseMessageSet(self):
    message = unittest_pb2.TestAllTypes()
    text = ('repeated_uint64: 1\n'
            'repeated_uint64: 2\n')
    text_format.Parse(text, message)
    self.assertEqual(1, message.repeated_uint64[0])
    self.assertEqual(2, message.repeated_uint64[1])

    message = unittest_mset_pb2.TestMessageSetContainer()
    text = ('message_set {\n'
            '  [protobuf_unittest.TestMessageSetExtension1] {\n'
            '    i: 23\n'
            '  }\n'
            '  [protobuf_unittest.TestMessageSetExtension2] {\n'
            '    str: \"foo\"\n'
            '  }\n'
            '}\n')
    text_format.Parse(text, message)
    ext1 = unittest_mset_pb2.TestMessageSetExtension1.message_set_extension
    ext2 = unittest_mset_pb2.TestMessageSetExtension2.message_set_extension
    self.assertEqual(23, message.message_set.Extensions[ext1].i)
    self.assertEqual('foo', message.message_set.Extensions[ext2].str) 
开发者ID:sklearn-theano,项目名称:sklearn-theano,代码行数:24,代码来源:text_format_test.py

示例9: testParseMessageSet

# 需要导入模块: from google.protobuf import unittest_mset_pb2 [as 别名]
# 或者: from google.protobuf.unittest_mset_pb2 import TestMessageSetContainer [as 别名]
def testParseMessageSet(self):
    message = unittest_pb2.TestAllTypes()
    text = ('repeated_uint64: 1\n'
            'repeated_uint64: 2\n')
    text_format.Parse(text, message)
    self.assertEqual(1, message.repeated_uint64[0])
    self.assertEqual(2, message.repeated_uint64[1])

    message = unittest_mset_pb2.TestMessageSetContainer()
    text = ('message_set {\n'
            '  [protobuf_unittest.TestMessageSetExtension1] {\n'
            '    i: 23\n'
            '  }\n'
            '  [protobuf_unittest.TestMessageSetExtension2] {\n'
            '    str: \"foo\"\n'
            '  }\n'
            '}\n')
    text_format.Parse(text, message)
    ext1 = unittest_mset_pb2.TestMessageSetExtension1.message_set_extension
    ext2 = unittest_mset_pb2.TestMessageSetExtension2.message_set_extension
    self.assertEquals(23, message.message_set.Extensions[ext1].i)
    self.assertEquals('foo', message.message_set.Extensions[ext2].str) 
开发者ID:katharosada,项目名称:botchallenge,代码行数:24,代码来源:text_format_test.py

示例10: testMergeMessageSet

# 需要导入模块: from google.protobuf import unittest_mset_pb2 [as 别名]
# 或者: from google.protobuf.unittest_mset_pb2 import TestMessageSetContainer [as 别名]
def testMergeMessageSet(self):
    message = unittest_pb2.TestAllTypes()
    text = ('repeated_uint64: 1\n'
            'repeated_uint64: 2\n')
    text_format.Merge(text, message)
    self.assertEqual(1, message.repeated_uint64[0])
    self.assertEqual(2, message.repeated_uint64[1])

    message = unittest_mset_pb2.TestMessageSetContainer()
    text = ('message_set {\n'
            '  [protobuf_unittest.TestMessageSetExtension1] {\n'
            '    i: 23\n'
            '  }\n'
            '  [protobuf_unittest.TestMessageSetExtension2] {\n'
            '    str: \"foo\"\n'
            '  }\n'
            '}\n')
    text_format.Merge(text, message)
    ext1 = unittest_mset_pb2.TestMessageSetExtension1.message_set_extension
    ext2 = unittest_mset_pb2.TestMessageSetExtension2.message_set_extension
    self.assertEquals(23, message.message_set.Extensions[ext1].i)
    self.assertEquals('foo', message.message_set.Extensions[ext2].str) 
开发者ID:apple,项目名称:coremltools,代码行数:24,代码来源:text_format_test.py


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