def testmergeallextensions(self):
    message = unittest_pb2.testallextensions()
    test_util.setallextensions(message)
    ascii_text = text_format.messagetostring(message)

    parsed_message = unittest_pb2.testallextensions()
    text_format.merge(ascii_text, parsed_message)
    self.assertequal(message, parsed_message)
  def testmergegoldenextensions(self):
    golden_text = '\n'.join(self.readgolden(
        'text_format_unittest_extensions_data.txt'))
    parsed_message = unittest_pb2.testallextensions()
    text_format.merge(golden_text, parsed_message)

    message = unittest_pb2.testallextensions()
    test_util.setallextensions(message)
    self.assertequals(message, parsed_message)
Exemplo n.º 3
0
 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())
 def testprintallextensions(self):
   message = unittest_pb2.testallextensions()
   test_util.setallextensions(message)
   self.comparetogoldenfile(
     self.removeredundantzeros(text_format.messagetostring(message)),
     'text_format_unittest_extensions_data.txt')