本文整理匯總了Python中google.protobuf.internal.test_util.GoldenFile方法的典型用法代碼示例。如果您正苦於以下問題:Python test_util.GoldenFile方法的具體用法?Python test_util.GoldenFile怎麽用?Python test_util.GoldenFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類google.protobuf.internal.test_util
的用法示例。
在下文中一共展示了test_util.GoldenFile方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ReadGolden
# 需要導入模塊: from google.protobuf.internal import test_util [as 別名]
# 或者: from google.protobuf.internal.test_util import GoldenFile [as 別名]
def ReadGolden(self, golden_filename):
with test_util.GoldenFile(golden_filename) as f:
return (f.readlines() if str is bytes else # PY3
[golden_line.decode('utf-8') for golden_line in f])
示例2: testGoldenMessage
# 需要導入模塊: from google.protobuf.internal import test_util [as 別名]
# 或者: from google.protobuf.internal.test_util import GoldenFile [as 別名]
def testGoldenMessage(self):
golden_data = test_util.GoldenFile('golden_message').read()
golden_message = unittest_pb2.TestAllTypes()
golden_message.ParseFromString(golden_data)
test_util.ExpectAllFieldsSet(self, golden_message)
self.assertEqual(golden_data, golden_message.SerializeToString())
golden_copy = copy.deepcopy(golden_message)
self.assertEqual(golden_data, golden_copy.SerializeToString())
示例3: testGoldenExtensions
# 需要導入模塊: from google.protobuf.internal import test_util [as 別名]
# 或者: from google.protobuf.internal.test_util import GoldenFile [as 別名]
def testGoldenExtensions(self):
golden_data = test_util.GoldenFile('golden_message').read()
golden_message = unittest_pb2.TestAllExtensions()
golden_message.ParseFromString(golden_data)
all_set = unittest_pb2.TestAllExtensions()
test_util.SetAllExtensions(all_set)
self.assertEquals(all_set, golden_message)
self.assertEqual(golden_data, golden_message.SerializeToString())
golden_copy = copy.deepcopy(golden_message)
self.assertEqual(golden_data, golden_copy.SerializeToString())
示例4: testGoldenPackedMessage
# 需要導入模塊: from google.protobuf.internal import test_util [as 別名]
# 或者: from google.protobuf.internal.test_util import GoldenFile [as 別名]
def testGoldenPackedMessage(self):
golden_data = test_util.GoldenFile('golden_packed_fields_message').read()
golden_message = unittest_pb2.TestPackedTypes()
golden_message.ParseFromString(golden_data)
all_set = unittest_pb2.TestPackedTypes()
test_util.SetAllPackedFields(all_set)
self.assertEquals(all_set, golden_message)
self.assertEqual(golden_data, all_set.SerializeToString())
golden_copy = copy.deepcopy(golden_message)
self.assertEqual(golden_data, golden_copy.SerializeToString())
示例5: testGoldenPackedExtensions
# 需要導入模塊: from google.protobuf.internal import test_util [as 別名]
# 或者: from google.protobuf.internal.test_util import GoldenFile [as 別名]
def testGoldenPackedExtensions(self):
golden_data = test_util.GoldenFile('golden_packed_fields_message').read()
golden_message = unittest_pb2.TestPackedExtensions()
golden_message.ParseFromString(golden_data)
all_set = unittest_pb2.TestPackedExtensions()
test_util.SetAllPackedExtensions(all_set)
self.assertEquals(all_set, golden_message)
self.assertEqual(golden_data, all_set.SerializeToString())
golden_copy = copy.deepcopy(golden_message)
self.assertEqual(golden_data, golden_copy.SerializeToString())
示例6: ReadGolden
# 需要導入模塊: from google.protobuf.internal import test_util [as 別名]
# 或者: from google.protobuf.internal.test_util import GoldenFile [as 別名]
def ReadGolden(self, golden_filename):
f = test_util.GoldenFile(golden_filename)
golden_lines = f.readlines()
f.close()
return golden_lines