From aa5ed7acee90ee27ef1a2f26938cff4a618fc6c0 Mon Sep 17 00:00:00 2001 From: "Navid C. Constantinou" Date: Wed, 6 Sep 2023 10:25:12 +1000 Subject: [PATCH] test the exception error by quadilateral_area --- tests/test_grid_generation.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/test_grid_generation.py b/tests/test_grid_generation.py index 6dda9066..499afae0 100644 --- a/tests/test_grid_generation.py +++ b/tests/test_grid_generation.py @@ -57,6 +57,19 @@ def test_quadilateral_area(v1, v2, v3, v4, true_area): assert np.isclose(quadilateral_area(v1, v2, v3, v4), true_area) +v1 = latlon_to_cartesian(0, 0, R=2) +v2 = latlon_to_cartesian(90, 0, R=2) +v3 = latlon_to_cartesian(0, 90, R=2) +v4 = latlon_to_cartesian(-90, 0, R=2.1) + + +def test_quadilateral_area_exception(): + with pytest.raises(Exception) as excinfo: + quadilateral_area(v1, v2, v3, v4) + + assert str(excinfo.value) == "vectors provided must have the same length" + + # create a lat-lon mesh that covers 1/4 of the North Hemisphere lon1, lat1 = np.meshgrid(np.linspace(0, 90, 5), np.linspace(0, 90, 5)) area1 = 1 / 8 * (4 * np.pi)