Exemplo n.º 1
0
    def testpicklesupport(self):
        golden_data = test_util.goldenfile("golden_message").read()
        golden_message = unittest_pb2.testalltypes()
        golden_message.parsefromstring(golden_data)
        pickled_message = pickle.dumps(golden_message)

        unpickled_message = pickle.loads(pickled_message)
        self.assertequals(unpickled_message, golden_message)
Exemplo n.º 2
0
 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())
Exemplo n.º 3
0
 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())
Exemplo n.º 4
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 readgolden(self, golden_filename):
   f = test_util.goldenfile(golden_filename)
   golden_lines = f.readlines()
   f.close()
   return golden_lines