diff --git a/lib/iris/__init__.py b/lib/iris/__init__.py index b45a2d7b53..f88537d2dd 100644 --- a/lib/iris/__init__.py +++ b/lib/iris/__init__.py @@ -224,7 +224,7 @@ def __repr__(self): def __setattr__(self, name, value): if name in self.deprecated_options: level = self.deprecated_options[name] - if level == 'error': + if level == 'error' and not value: emsg = ("setting the 'Future' property {prop!r} has been " "deprecated to be removed in a future release, and " "deprecated {prop!r} behaviour has been removed. " diff --git a/lib/iris/tests/unit/test_Future.py b/lib/iris/tests/unit/test_Future.py index ee762254fd..707c39c7b9 100644 --- a/lib/iris/tests/unit/test_Future.py +++ b/lib/iris/tests/unit/test_Future.py @@ -43,22 +43,30 @@ def test_invalid_attribute(self): with self.assertRaises(AttributeError): future.numberwang = 7 - def test_invalid_netcdf_promote_attributes(self): + def test_netcdf_promote(self): future = Future() - states = [True, False] - exp_emsg = "deprecated 'netcdf_promote' behaviour has been removed" - for state in states: - with self.assertRaisesRegexp(AttributeError, exp_emsg): - future.netcdf_promote = state + exp_emsg = "'Future' property 'netcdf_promote' is deprecated" + with self.assertWarnsRegexp(exp_emsg): + future.netcdf_promote = True - def test_invalid_netcdf_no_unlimited_attributes(self): + def test_invalid_netcdf_promote(self): future = Future() - states = [True, False] - exp_emsg =\ - "deprecated 'netcdf_no_unlimited' behaviour has been removed" - for state in states: - with self.assertRaisesRegexp(AttributeError, exp_emsg): - future.netcdf_no_unlimited = state + exp_emsg = "'Future' property 'netcdf_promote' has been deprecated" + with self.assertRaisesRegexp(AttributeError, exp_emsg): + future.netcdf_promote = False + + def test_netcdf_no_unlimited(self): + future = Future() + exp_emsg = "'Future' property 'netcdf_no_unlimited' is deprecated" + with self.assertWarnsRegexp(exp_emsg): + future.netcdf_no_unlimited = True + + def test_invalid_netcdf_no_unlimited(self): + future = Future() + exp_emsg = \ + "'Future' property 'netcdf_no_unlimited' has been deprecated" + with self.assertRaisesRegexp(AttributeError, exp_emsg): + future.netcdf_no_unlimited = False def test_cell_datetime_objects(self): future = Future()