From 9edad60a923f8d0ec609b8232c59d2161d04d5e3 Mon Sep 17 00:00:00 2001 From: David Hoese Date: Mon, 4 Jan 2021 15:37:36 -0600 Subject: [PATCH] Fix test_ancillary_variables for CF writer --- satpy/tests/writer_tests/test_cf.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/satpy/tests/writer_tests/test_cf.py b/satpy/tests/writer_tests/test_cf.py index 084c2193f0..b9e1057415 100644 --- a/satpy/tests/writer_tests/test_cf.py +++ b/satpy/tests/writer_tests/test_cf.py @@ -139,13 +139,14 @@ def test_ancillary_variables(self): """Test ancillary_variables cited each other.""" import xarray as xr from satpy import Scene + from satpy.tests.utils import make_dataid scn = Scene() start_time = datetime(2018, 5, 30, 10, 0) end_time = datetime(2018, 5, 30, 10, 15) da = xr.DataArray([1, 2, 3], attrs=dict(start_time=start_time, end_time=end_time, - prerequisites=[DatasetID('hej')])) + prerequisites=[make_dataid(name='hej')])) scn['test-array-1'] = da scn['test-array-2'] = da.copy() scn['test-array-1'].attrs['ancillary_variables'] = [scn['test-array-2']] @@ -990,7 +991,7 @@ def test_load_module_with_old_pyproj(self): importlib.reload(sys.modules['satpy.writers.cf_writer']) def test_global_attr_default_history_and_Conventions(self): - """Test saving global attributes history and Conventions""" + """Test saving global attributes history and Conventions.""" from satpy import Scene import xarray as xr scn = Scene() @@ -1008,7 +1009,7 @@ def test_global_attr_default_history_and_Conventions(self): self.assertIn('Created by pytroll/satpy on', f.attrs['history']) def test_global_attr_history_and_Conventions(self): - """Test saving global attributes history and Conventions""" + """Test saving global attributes history and Conventions.""" from satpy import Scene import xarray as xr scn = Scene() @@ -1106,7 +1107,9 @@ def test_collect_datasets_with_latitude_named_lat(self, *mocks): class EncodingUpdateTest(unittest.TestCase): """Test update of netCDF encoding.""" + def setUp(self): + """Create fake data for testing.""" import xarray as xr self.ds = xr.Dataset({'foo': (('y', 'x'), [[1, 2], [3, 4]]), 'bar': (('y', 'x'), [[3, 4], [5, 6]])}, @@ -1115,6 +1118,7 @@ def setUp(self): 'lon': (('y', 'x'), [[7, 8], [9, 10]])}) def test_without_time(self): + """Test data without a time dimension.""" from satpy.writers.cf_writer import update_encoding # Without time dimension @@ -1140,6 +1144,7 @@ def test_without_time(self): 'bar': {'chunksizes': (2, 2)}}) def test_with_time(self): + """Test data with a time dimension.""" from satpy.writers.cf_writer import update_encoding # With time dimension