本文整理匯總了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())