def test_serialize_protocol_version_4(self, mock_pickle_dumps): test_string = 'some maybe large string' serializer.serialize(test_string) mock_pickle_dumps.assert_called_with(test_string, protocol=4)
def test_serialize_saves_magic(self): import pickle magic = serializer.serialize('A')[:4] self.assertEqual(b'FNDS', magic)
def test_deserialize_can_load_serialized_data_different_value(self): serialized_data = serializer.serialize(9.34343) self.assertEqual(9.34343, serializer.deserialize(serialized_data))
def test_deserialize_can_load_serialized_data(self): serialized_data = serializer.serialize('A') self.assertEqual('A', serializer.deserialize(serialized_data))
def test_serialize_can_serialize_pickle_with_header_different_value(self): import pickle serialized_data = serializer.serialize(Exception)[4:] self.assertEqual(Exception, pickle.loads(serialized_data))
def test_serialize_can_serialize_pickle_with_header(self): import pickle serialized_data = serializer.serialize('A')[4:] self.assertEqual('A', pickle.loads(serialized_data))
def _fast_serialize(self, data): from foundations_internal.fast_serializer import serialize return serialize(data)