Skip to content

Commit cce98d4

Browse files
committed
fix tests
1 parent d6d695a commit cce98d4

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

tests/test_save.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@ def model_with_setup(self, tmp_path):
4545
with patch("time.strftime") as mocked_time:
4646
mocked_time.return_value = "2022-08-01-1200"
4747

48-
_ = model.setup(
48+
config_path = model.setup(
4949
WorkDir = str(tmp_path),
5050
ForcingFileName = "dummy_forcing_file.nc",
5151
NumberOfTimeSteps = "3", # less than forcing temporal range
5252
)
53-
return model
53+
return model, config_path
5454

5555
def test_save_to_netcdf(self, cf_convention, model_with_setup):
56-
model = model_with_setup
57-
saved_nc_file = save.to_netcdf(model.config, cf_convention)
56+
model, config_path = model_with_setup
57+
saved_nc_file = save.to_netcdf(config_path, cf_convention)
5858

5959
expected_nc_file = (
6060
"tests/test_data/directories/output/dummy-2022-08-01-1200/dummy-2022-08-01-1200_STEMMUS_SCOPE.nc"
@@ -110,16 +110,16 @@ def model_with_setup(self, tmp_path):
110110
with patch("time.strftime") as mocked_time:
111111
mocked_time.return_value = "2022-08-01-1200"
112112

113-
_ = model.setup(
113+
config_path = model.setup(
114114
WorkDir = str(tmp_path),
115115
ForcingFileName = "dummy_forcing_file.nc",
116116
NumberOfTimeSteps = "NA", # use temporal range of forcing data
117117
)
118-
return model
118+
return model, config_path
119119

120120
@pytest.fixture(name="_make_csv_file")
121121
def fixture_make_csv_file(self, model_with_setup):
122-
model = model_with_setup
122+
model, _ = model_with_setup
123123
data = [
124124
"simulation_number,year,DoY,Netlong",
125125
",,,W m-2",
@@ -134,8 +134,8 @@ def fixture_make_csv_file(self, model_with_setup):
134134
write_csv(data, csv_file)
135135

136136
def test_save_to_netcdf(self, cf_convention, _make_csv_file, model_with_setup):
137-
model = model_with_setup
138-
saved_nc_file = save.to_netcdf(model.config, cf_convention)
137+
model, config_path = model_with_setup
138+
saved_nc_file = save.to_netcdf(config_path, cf_convention)
139139

140140
expected_nc_file = (
141141
"tests/test_data/directories/output/dummy-2022-08-01-1200/dummy-2022-08-01-1200_STEMMUS_SCOPE.nc"
@@ -193,16 +193,16 @@ def model_with_setup(self, tmp_path):
193193
with patch("time.strftime") as mocked_time:
194194
mocked_time.return_value = "2022-08-01-1200"
195195

196-
_ = model.setup(
196+
config_path = model.setup(
197197
WorkDir = str(tmp_path),
198198
ForcingFileName = "dummy_forcing_file.nc",
199199
NumberOfTimeSteps = "5",
200200
)
201-
return model
201+
return model, config_path
202202

203203
@pytest.fixture(name="_make_csv_file")
204204
def fixture_make_csv_file(self, model_with_setup):
205-
model = model_with_setup
205+
model, _ = model_with_setup
206206
data = [
207207
"1,2,3,5",
208208
"1,1,1,2",
@@ -218,8 +218,8 @@ def fixture_make_csv_file(self, model_with_setup):
218218
write_csv(data, csv_file)
219219

220220
def test_save_to_netcdf(self, cf_convention, _make_csv_file, model_with_setup):
221-
model = model_with_setup
222-
saved_nc_file = save.to_netcdf(model.config, cf_convention)
221+
model, config_path = model_with_setup
222+
saved_nc_file = save.to_netcdf(config_path, cf_convention)
223223

224224
expected_nc_file = (
225225
"tests/test_data/directories/output/dummy-2022-08-01-1200/dummy-2022-08-01-1200_STEMMUS_SCOPE.nc"
@@ -282,16 +282,16 @@ def model_with_setup(self, tmp_path):
282282
with patch("time.strftime") as mocked_time:
283283
mocked_time.return_value = "2022-08-01-1200"
284284

285-
_ = model.setup(
285+
config_path = model.setup(
286286
WorkDir = str(tmp_path),
287287
ForcingFileName = "dummy_forcing_file.nc",
288288
NumberOfTimeSteps = "NA",
289289
)
290-
return model
290+
return model, config_path
291291

292292
@pytest.fixture(name="_make_csv_file")
293293
def fixture_make_csv_file(self, model_with_setup):
294-
model = model_with_setup
294+
model, _ = model_with_setup
295295
data = [
296296
"1,2,3,5",
297297
"1,1,1,2",
@@ -318,8 +318,8 @@ def fixture_make_csv_file(self, model_with_setup):
318318
write_csv(data, csv_file)
319319

320320
def test_save_to_netcdf(self, cf_convention, _make_csv_file, model_with_setup):
321-
model = model_with_setup
322-
saved_nc_file = save.to_netcdf(model.config, cf_convention)
321+
model, config_path = model_with_setup
322+
saved_nc_file = save.to_netcdf(config_path, cf_convention)
323323

324324
expected_nc_file = (
325325
"tests/test_data/directories/output/dummy-2022-08-01-1200/dummy-2022-08-01-1200_STEMMUS_SCOPE.nc"

0 commit comments

Comments
 (0)