File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 11"""Unit tests for :func:`esmvalcore._data_finder.regrid._stock_cube`"""
22
3- import tempfile
43import iris
54import pytest
65
@@ -31,16 +30,17 @@ def test_get_start_end_year(case):
3130 assert case_end == end
3231
3332
34- def test_read_time_from_cube ():
33+ def test_read_time_from_cube (monkeypatch , tmp_path ):
3534 """Try to get time from cube if no date in filename"""
36- temp_file = tempfile .NamedTemporaryFile (suffix = '.nc' )
35+ monkeypatch .chdir (tmp_path )
36+ temp_file = 'test.nc'
3737 cube = iris .cube .Cube ([0 , 0 ], var_name = 'var' )
3838 time = iris .coords .DimCoord ([0 , 366 ],
3939 'time' ,
4040 units = 'days since 1990-01-01' )
4141 cube .add_dim_coord (time , 0 )
42- iris .save (cube , temp_file . name )
43- start , end = get_start_end_year (temp_file . name )
42+ iris .save (cube , temp_file )
43+ start , end = get_start_end_year (temp_file )
4444 assert start == 1990
4545 assert end == 1991
4646
You can’t perform that action at this time.
0 commit comments