3
3
import pytest
4
4
5
5
from esmvalcore .local import (
6
+ LocalFile ,
6
7
_dates_to_timerange ,
7
8
_get_start_end_date ,
8
9
_get_start_end_year ,
64
65
def test_get_start_end_year (case ):
65
66
"""Tests for _get_start_end_year function."""
66
67
filename , case_start , case_end = case
68
+ filename = LocalFile (filename )
67
69
if case_start is None and case_end is None :
68
70
# If the filename is inconclusive or too difficult
69
71
# we resort to reading the file, which fails here
@@ -80,6 +82,7 @@ def test_get_start_end_year(case):
80
82
def test_get_start_end_date (case ):
81
83
"""Tests for _get_start_end_date function."""
82
84
filename , case_start , case_end = case
85
+ filename = LocalFile (filename )
83
86
if case_start is None and case_end is None :
84
87
# If the filename is inconclusive or too difficult
85
88
# we resort to reading the file, which fails here
@@ -95,7 +98,7 @@ def test_get_start_end_date(case):
95
98
def test_read_time_from_cube (monkeypatch , tmp_path ):
96
99
"""Try to get time from cube if no date in filename."""
97
100
monkeypatch .chdir (tmp_path )
98
- temp_file = 'test.nc'
101
+ temp_file = LocalFile ( 'test.nc' )
99
102
cube = iris .cube .Cube ([0 , 0 ], var_name = 'var' )
100
103
time = iris .coords .DimCoord ([0 , 366 ],
101
104
'time' ,
@@ -142,9 +145,7 @@ def test_fails_if_no_date_present():
142
145
def test_get_timerange_from_years ():
143
146
"""Test a `timerange` tag with value `start_year/end_year` can be built
144
147
from tags `start_year` and `end_year`."""
145
- variable = {
146
- 'start_year' : 2000 ,
147
- 'end_year' : 2002 }
148
+ variable = {'start_year' : 2000 , 'end_year' : 2002 }
148
149
149
150
_replace_years_with_timerange (variable )
150
151
@@ -156,9 +157,7 @@ def test_get_timerange_from_years():
156
157
def test_get_timerange_from_start_year ():
157
158
"""Test a `timerange` tag with value `start_year/start_year` can be built
158
159
from tag `start_year` when an `end_year` is not given."""
159
- variable = {
160
- 'start_year' : 2000
161
- }
160
+ variable = {'start_year' : 2000 }
162
161
163
162
_replace_years_with_timerange (variable )
164
163
@@ -169,9 +168,7 @@ def test_get_timerange_from_start_year():
169
168
def test_get_timerange_from_end_year ():
170
169
"""Test a `timerange` tag with value `end_year/end_year` can be built from
171
170
tag `end_year` when a `start_year` is not given."""
172
- variable = {
173
- 'end_year' : 2002
174
- }
171
+ variable = {'end_year' : 2002 }
175
172
176
173
_replace_years_with_timerange (variable )
177
174
0 commit comments