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
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)
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)
def testprintallfields(self): message = unittest_pb2.testalltypes() test_util.setallfields(message) self.comparetogoldenfile( self.removeredundantzeros(text_format.messagetostring(message)), 'text_format_unittest_data.txt')