1616import numpy as np
1717import pytest
1818
19+ import iris .fileformats .netcdf ._bytecoding_datasets as bytecoding_datasets
1920import iris .fileformats .netcdf ._thread_safe_nc as threadsafe_nc
2021from iris .fileformats .netcdf .saver import Saver
2122
@@ -52,9 +53,10 @@ def data_form(request) -> Iterator[bool]:
5253 return request .param
5354
5455 @staticmethod
55- def saver (compute ) -> Saver :
56+ def saver (compute , data_form , tmp_path ) -> Saver :
5657 # Create a test Saver object
57- return Saver (filename = "<dummy>" , netcdf_format = "NETCDF4" , compute = compute )
58+ filepath = tmp_path / f"tmp_{ compute } _{ data_form } .nc"
59+ return Saver (filename = filepath , netcdf_format = "NETCDF4" , compute = compute )
5860
5961 @staticmethod
6062 def mock_var (shape , with_data_array , mocker ):
@@ -68,6 +70,7 @@ def mock_var(shape, with_data_array, mocker):
6870 spec = threadsafe_nc .VariableWrapper ,
6971 shape = tuple (shape ),
7072 dtype = np .dtype (np .float32 ),
73+ _contained_instance = mocker .Mock (dtype = "f4" ),
7174 ** extra_properties ,
7275 )
7376 # Give the mock cf-var a name property, as required by '_lazy_stream_data'.
@@ -76,9 +79,9 @@ def mock_var(shape, with_data_array, mocker):
7679 mock_cfvar .name = "<mock_cfvar>"
7780 return mock_cfvar
7881
79- def test_data_save (self , compute , data_form , mocker ):
82+ def test_data_save (self , compute , data_form , mocker , tmp_path ):
8083 """Real data is transferred immediately, lazy data creates a delayed write."""
81- saver = self .saver (compute = compute )
84+ saver = self .saver (compute , data_form , tmp_path )
8285
8386 data = np .arange (5.0 )
8487 if data_form == "lazydata" :
0 commit comments