本文整理汇总了Python中google.protobuf.internal.api_implementation.Version方法的典型用法代码示例。如果您正苦于以下问题:Python api_implementation.Version方法的具体用法?Python api_implementation.Version怎么用?Python api_implementation.Version使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类google.protobuf.internal.api_implementation
的用法示例。
在下文中一共展示了api_implementation.Version方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from google.protobuf.internal import api_implementation [as 别名]
# 或者: from google.protobuf.internal.api_implementation import Version [as 别名]
def __init__(self, name, package, options=None, serialized_pb=None,
dependencies=None):
"""Constructor."""
super(FileDescriptor, self).__init__(options, 'FileOptions')
self.message_types_by_name = {}
self.name = name
self.package = package
self.serialized_pb = serialized_pb
self.enum_types_by_name = {}
self.extensions_by_name = {}
self.dependencies = (dependencies or [])
if (api_implementation.Type() == 'cpp' and
self.serialized_pb is not None):
if api_implementation.Version() == 2:
# pylint: disable=protected-access
_message.Message._BuildFile(self.serialized_pb)
# pylint: enable=protected-access
else:
cpp_message.BuildFile(self.serialized_pb)
示例2: testPickleRepeatedScalarContainer
# 需要导入模块: from google.protobuf.internal import api_implementation [as 别名]
# 或者: from google.protobuf.internal.api_implementation import Version [as 别名]
def testPickleRepeatedScalarContainer(self, message_module):
# TODO(tibell): The pure-Python implementation support pickling of
# scalar containers in *some* cases. For now the cpp2 version
# throws an exception to avoid a segfault. Investigate if we
# want to support pickling of these fields.
#
# For more information see: https://b2.corp.google.com/u/0/issues/18677897
if (api_implementation.Type() != 'cpp' or
api_implementation.Version() == 2):
return
m = message_module.TestAllTypes()
with self.assertRaises(pickle.PickleError) as _:
pickle.dumps(m.repeated_int32, pickle.HIGHEST_PROTOCOL)
示例3: SkipCheckUnknownFieldIfCppImplementation
# 需要导入模块: from google.protobuf.internal import api_implementation [as 别名]
# 或者: from google.protobuf.internal.api_implementation import Version [as 别名]
def SkipCheckUnknownFieldIfCppImplementation(func):
return unittest.skipIf(
api_implementation.Type() == 'cpp' and api_implementation.Version() == 2,
'Addtional test for pure python involved protect members')(func)
示例4: SkipIfCppImplementation
# 需要导入模块: from google.protobuf.internal import api_implementation [as 别名]
# 或者: from google.protobuf.internal.api_implementation import Version [as 别名]
def SkipIfCppImplementation(func):
return unittest.skipIf(
api_implementation.Type() == 'cpp' and api_implementation.Version() == 2,
'C++ implementation does not expose unknown fields to Python')(func)
示例5: testThatCppApiV2IsTheDefault
# 需要导入模块: from google.protobuf.internal import api_implementation [as 别名]
# 或者: from google.protobuf.internal.api_implementation import Version [as 别名]
def testThatCppApiV2IsTheDefault(self):
"""If -DPYTHON_PROTO_*IMPL* was given at build time, this may fail."""
self.assertEqual('cpp', api_implementation.Type())
self.assertEqual(2, api_implementation.Version())