Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion lib/iris/tests/integration/test_pickle.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2014 - 2016, Met Office
# (C) British Crown Copyright 2014 - 2017, Met Office
#
# This file is part of Iris.
#
Expand All @@ -25,6 +25,7 @@

import six.moves.cPickle as pickle

import iris
if tests.GRIB_AVAILABLE:
import gribapi
from iris.fileformats.grib.message import GribMessage
Expand Down Expand Up @@ -52,5 +53,36 @@ def test_data(self):
pickle.dump(message.data, f)


class Common(object):
# Ensure that data proxies are pickleable.
def pickle_cube(self, path):
cube = iris.load(path)[0]
with self.temp_filename('.pkl') as filename:
with open(filename, 'wb') as f:
pickle.dump(cube, f)


@tests.skip_data
class test_netcdf(Common, tests.IrisTest):
def test(self):
path = tests.get_data_path(('NetCDF', 'global', 'xyt',
'SMALL_hires_wind_u_for_ipcc4.nc'))
self.pickle_cube(path)


@tests.skip_data
class test_pp(Common, tests.IrisTest):
def test(self):
path = tests.get_data_path(('PP', 'aPPglob1', 'global.pp'))
self.pickle_cube(path)


@tests.skip_data
class test_ff(Common, tests.IrisTest):
def test(self):
path = tests.get_data_path(('FF', 'n48_multi_field'))
self.pickle_cube(path)


if __name__ == '__main__':
tests.main()