コード例 #1
0
 def setup(self):
   self.descriptor = unittest_pb2.testalltypes.descriptor
   self.all_fields = unittest_pb2.testalltypes()
   test_util.setallfields(self.all_fields)
   self.all_fields_data = self.all_fields.serializetostring()
   self.empty_message = unittest_pb2.testemptymessage()
   self.empty_message.parsefromstring(self.all_fields_data)
   self.unknown_fields = self.empty_message._unknown_fields
コード例 #2
0
  def testmergegolden(self):
    golden_text = '\n'.join(self.readgolden('text_format_unittest_data.txt'))
    parsed_message = unittest_pb2.testalltypes()
    text_format.merge(golden_text, parsed_message)

    message = unittest_pb2.testalltypes()
    test_util.setallfields(message)
    self.assertequals(message, parsed_message)
コード例 #3
0
  def testmergeallfields(self):
    message = unittest_pb2.testalltypes()
    test_util.setallfields(message)
    ascii_text = text_format.messagetostring(message)

    parsed_message = unittest_pb2.testalltypes()
    text_format.merge(ascii_text, parsed_message)
    self.assertequal(message, parsed_message)
    test_util.expectallfieldsset(self, message)
コード例 #4
0
 def testprintallfields(self):
   message = unittest_pb2.testalltypes()
   test_util.setallfields(message)
   self.comparetogoldenfile(
     self.removeredundantzeros(text_format.messagetostring(message)),
     'text_format_unittest_data.txt')