Skip to content

Commit

Permalink
cleaner tests
Browse files Browse the repository at this point in the history
  • Loading branch information
navidcy committed Apr 23, 2024
1 parent 637739e commit 55ab4cc
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions tests/test_expt_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,60 +317,56 @@ def test_ocean_forcing(
arakawa_grid="A",
)

# test whether ValueError is raised if IC is missing a variable
error_msg_missing_tracer = (
"Error while reading initial condition tracers. Terminating!"
)
error_msg_missing_velocity = (
"Error while reading initial condition velocities. Terminating!"
)
error_msg_missing_free_surface = (
"Error while reading initial condition free surface. Terminating!"
)

with pytest.raises(ValueError) as excinfo:
expt.initial_condition(
tmp_path / "ic_without_u_unprocessed",
varnames,
arakawa_grid="A",
)
assert (
str(excinfo.value)
== "Error while reading initial condition velocities. Terminating!"
)
assert str(excinfo.value) == error_msg_missing_velocity

with pytest.raises(ValueError) as excinfo:
expt.initial_condition(
tmp_path / "ic_without_v_unprocessed",
varnames,
arakawa_grid="A",
)
assert (
str(excinfo.value)
== "Error while reading initial condition velocities. Terminating!"
)
assert str(excinfo.value) == error_msg_missing_velocity

with pytest.raises(ValueError) as excinfo:
expt.initial_condition(
tmp_path / "ic_without_temp_unprocessed",
varnames,
arakawa_grid="A",
)
assert (
str(excinfo.value)
== "Error while reading initial condition tracers. Terminating!"
)
assert str(excinfo.value) == error_msg_missing_tracer

with pytest.raises(ValueError) as excinfo:
expt.initial_condition(
tmp_path / "ic_without_salt_unprocessed",
varnames,
arakawa_grid="A",
)
assert (
str(excinfo.value)
== "Error while reading initial condition tracers. Terminating!"
)
assert str(excinfo.value) == error_msg_missing_tracer

with pytest.raises(ValueError) as excinfo:
expt.initial_condition(
tmp_path / "ic_without_eta_unprocessed",
varnames,
arakawa_grid="A",
)
assert (
str(excinfo.value)
== "Error while reading initial condition free surface. Terminating!"
)
assert str(excinfo.value) == error_msg_missing_free_surface


@pytest.mark.parametrize(
Expand Down

0 comments on commit 55ab4cc

Please sign in to comment.