From 7c4f7003aafa77a798c9cc0514654c3dbb927343 Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Wed, 13 Mar 2024 15:40:20 +0000 Subject: [PATCH] Demonstrate new check_graphic in test_plot. --- lib/iris/tests/test_plot.py | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/lib/iris/tests/test_plot.py b/lib/iris/tests/test_plot.py index 64f128c408..12509b4707 100644 --- a/lib/iris/tests/test_plot.py +++ b/lib/iris/tests/test_plot.py @@ -13,6 +13,7 @@ import cf_units import numpy as np +import pytest import iris import iris.analysis @@ -240,14 +241,15 @@ def setUp(self): @tests.skip_data @tests.skip_plot -class Test1dScatter(tests.GraphicsTest): - def setUp(self): - super().setUp() +class Test1dScatter: + @pytest.fixture(autouse=True) + def setup(self, check_graphic_caller): self.cube = iris.load_cube( tests.get_data_path(("NAME", "NAMEIII_trajectory.txt")), "Temperature", ) self.draw_method = iplt.scatter + self.check_graphic = check_graphic_caller def test_coord_coord(self): x = self.cube.coord("longitude") @@ -288,27 +290,6 @@ def test_cube_cube(self): self.draw_method(x, y, c=c, edgecolor="none") self.check_graphic() - def test_incompatible_objects(self): - # cubes/coordinates of different sizes cannot be plotted - x = self.cube - y = self.cube.coord("altitude")[:-1] - with self.assertRaises(ValueError): - self.draw_method(x, y) - - def test_multidimensional(self): - # multidimensional cubes/coordinates are not allowed - x = _load_4d_testcube()[0, :, :, 0] - y = x.coord("model_level_number") - with self.assertRaises(ValueError): - self.draw_method(x, y) - - def test_not_cube_or_coord(self): - # inputs must be cubes or coordinates - x = np.arange(self.cube.shape[0]) - y = self.cube - with self.assertRaises(TypeError): - self.draw_method(x, y) - @tests.skip_data @tests.skip_plot