diff --git a/lib/iris/tests/unit/fileformats/name_loaders/test__build_cell_methods.py b/lib/iris/tests/unit/fileformats/name_loaders/test__build_cell_methods.py index ff80acf95b..6b7d576cf5 100644 --- a/lib/iris/tests/unit/fileformats/name_loaders/test__build_cell_methods.py +++ b/lib/iris/tests/unit/fileformats/name_loaders/test__build_cell_methods.py @@ -3,42 +3,37 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Unit tests for :func:`iris.fileformats.name_loaders._build_cell_methods`.""" - -# Import iris.tests first so that some things can be initialised before -# importing anything else. -import iris.tests as tests # isort:skip - -from unittest import mock +import pytest import iris.coords from iris.fileformats.name_loaders import _build_cell_methods from iris.warnings import IrisLoadWarning -class Tests(tests.IrisTest): - def test_nameII_average(self): +class Tests: + def test_name_ii_average(self): av_or_int = ["something average ob bla"] coord_name = "foo" res = _build_cell_methods(av_or_int, coord_name) - self.assertEqual(res, [iris.coords.CellMethod("mean", "foo")]) + assert res == [iris.coords.CellMethod("mean", "foo")] - def test_nameIII_averaged(self): + def test_name_iii_averaged(self): av_or_int = ["something averaged ob bla"] coord_name = "bar" res = _build_cell_methods(av_or_int, coord_name) - self.assertEqual(res, [iris.coords.CellMethod("mean", "bar")]) + assert res == [iris.coords.CellMethod("mean", "bar")] - def test_nameII_integral(self): + def test_name_ii_integral(self): av_or_int = ["something integral ob bla"] coord_name = "ensemble" res = _build_cell_methods(av_or_int, coord_name) - self.assertEqual(res, [iris.coords.CellMethod("sum", "ensemble")]) + assert res == [iris.coords.CellMethod("sum", "ensemble")] - def test_nameIII_integrated(self): + def test_name_iii_integrated(self): av_or_int = ["something integrated ob bla"] coord_name = "time" res = _build_cell_methods(av_or_int, coord_name) - self.assertEqual(res, [iris.coords.CellMethod("sum", "time")]) + assert res == [iris.coords.CellMethod("sum", "time")] def test_no_averaging(self): av_or_int = [ @@ -51,9 +46,9 @@ def test_no_averaging(self): ] coord_name = "time" res = _build_cell_methods(av_or_int, coord_name) - self.assertEqual(res, [None] * len(av_or_int)) + assert res == [None] * len(av_or_int) - def test_nameII_mixed(self): + def test_name_ii_mixed(self): av_or_int = [ "something integral ob bla", "no averaging", @@ -61,16 +56,13 @@ def test_nameII_mixed(self): ] coord_name = "ensemble" res = _build_cell_methods(av_or_int, coord_name) - self.assertEqual( - res, - [ - iris.coords.CellMethod("sum", "ensemble"), - None, - iris.coords.CellMethod("mean", "ensemble"), - ], - ) + assert res == [ + iris.coords.CellMethod("sum", "ensemble"), + None, + iris.coords.CellMethod("mean", "ensemble"), + ] - def test_nameIII_mixed(self): + def test_name_iii_mixed(self): av_or_int = [ "something integrated ob bla", "no averaging", @@ -78,14 +70,11 @@ def test_nameIII_mixed(self): ] coord_name = "ensemble" res = _build_cell_methods(av_or_int, coord_name) - self.assertEqual( - res, - [ - iris.coords.CellMethod("sum", "ensemble"), - None, - iris.coords.CellMethod("mean", "ensemble"), - ], - ) + assert res == [ + iris.coords.CellMethod("sum", "ensemble"), + None, + iris.coords.CellMethod("mean", "ensemble"), + ] def test_unrecognised(self): unrecognised_heading = "bla else" @@ -95,14 +84,13 @@ def test_unrecognised(self): "something integral", ] coord_name = "foo" - with mock.patch("warnings.warn") as warn: - _ = _build_cell_methods(av_or_int, coord_name) expected_msg = ( "Unknown {} statistic: {!r}. Unable to create cell method.".format( coord_name, unrecognised_heading ) ) - warn.assert_called_with(expected_msg, category=IrisLoadWarning) + with pytest.warns(IrisLoadWarning, match=expected_msg): + _ = _build_cell_methods(av_or_int, coord_name) def test_unrecognised_similar_to_no_averaging(self): unrecognised_headings = [ @@ -121,15 +109,10 @@ def test_unrecognised_similar_to_no_averaging(self): "something integral", ] coord_name = "foo" - with mock.patch("warnings.warn") as warn: - _ = _build_cell_methods(av_or_int, coord_name) expected_msg = ( "Unknown {} statistic: {!r}. Unable to create cell method.".format( coord_name, unrecognised_heading ) ) - warn.assert_called_with(expected_msg, category=IrisLoadWarning) - - -if __name__ == "__main__": - tests.main() + with pytest.warns(IrisLoadWarning, match=expected_msg): + _ = _build_cell_methods(av_or_int, coord_name) diff --git a/lib/iris/tests/unit/fileformats/name_loaders/test__build_lat_lon_for_NAME_timeseries.py b/lib/iris/tests/unit/fileformats/name_loaders/test__build_lat_lon_for_NAME_timeseries.py index 9cc7ec356a..ce8fbdff06 100644 --- a/lib/iris/tests/unit/fileformats/name_loaders/test__build_lat_lon_for_NAME_timeseries.py +++ b/lib/iris/tests/unit/fileformats/name_loaders/test__build_lat_lon_for_NAME_timeseries.py @@ -3,29 +3,25 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Unit tests for :func:`iris.analysis.name_loaders._build_lat_lon_for_NAME_timeseries`.""" - -# Import iris.tests first so that some things can be initialised before -# importing anything else. -import iris.tests as tests # isort:skip - from iris.fileformats.name_loaders import NAMECoord, _build_lat_lon_for_NAME_timeseries +from iris.tests._shared_utils import assert_array_equal -class TestCellMethods(tests.IrisTest): +class TestCellMethods: def test_float(self): column_headings = { "X": ["X = -.100 Lat-Long", "X = -1.600 Lat-Long"], "Y": ["Y = 52.450 Lat-Long", "Y = 51. Lat-Long"], } lat, lon = _build_lat_lon_for_NAME_timeseries(column_headings) - self.assertIsInstance(lat, NAMECoord) - self.assertIsInstance(lon, NAMECoord) - self.assertEqual(lat.name, "latitude") - self.assertEqual(lon.name, "longitude") - self.assertIsNone(lat.dimension) - self.assertIsNone(lon.dimension) - self.assertArrayEqual(lat.values, [52.45, 51.0]) - self.assertArrayEqual(lon.values, [-0.1, -1.6]) + assert isinstance(lat, NAMECoord) + assert isinstance(lon, NAMECoord) + assert lat.name == "latitude" + assert lon.name == "longitude" + assert lat.dimension is None + assert lon.dimension is None + assert_array_equal(lat.values, [52.45, 51.0]) + assert_array_equal(lon.values, [-0.1, -1.6]) def test_int(self): column_headings = { @@ -33,13 +29,13 @@ def test_int(self): "Y": ["Y = 52 Lat-Long", "Y = 51 Lat-Long"], } lat, lon = _build_lat_lon_for_NAME_timeseries(column_headings) - self.assertIsInstance(lat, NAMECoord) - self.assertIsInstance(lon, NAMECoord) - self.assertEqual(lat.name, "latitude") - self.assertEqual(lon.name, "longitude") - self.assertIsNone(lat.dimension) - self.assertIsNone(lon.dimension) - self.assertArrayEqual(lat.values, [52.0, 51.0]) - self.assertArrayEqual(lon.values, [-1.0, -2.0]) - self.assertIsInstance(lat.values[0], float) - self.assertIsInstance(lon.values[0], float) + assert isinstance(lat, NAMECoord) + assert isinstance(lon, NAMECoord) + assert lat.name == "latitude" + assert lon.name == "longitude" + assert lat.dimension is None + assert lon.dimension is None + assert_array_equal(lat.values, [52.0, 51.0]) + assert_array_equal(lon.values, [-1.0, -2.0]) + assert isinstance(lat.values[0], float) + assert isinstance(lon.values[0], float) diff --git a/lib/iris/tests/unit/fileformats/name_loaders/test__calc_integration_period.py b/lib/iris/tests/unit/fileformats/name_loaders/test__calc_integration_period.py index 35ca2760b8..f94b4b4857 100644 --- a/lib/iris/tests/unit/fileformats/name_loaders/test__calc_integration_period.py +++ b/lib/iris/tests/unit/fileformats/name_loaders/test__calc_integration_period.py @@ -3,59 +3,50 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Unit tests for :func:`iris.fileformats.name_loaders.__calc_integration_period`.""" - -# Import iris.tests first so that some things can be initialised before -# importing anything else. -import iris.tests as tests # isort:skip - import datetime from iris.fileformats.name_loaders import _calc_integration_period -class Test(tests.IrisTest): +class Test: def test_30_min_av(self): time_avgs = [" 30min average"] result = _calc_integration_period(time_avgs) expected = [datetime.timedelta(0, (30 * 60))] - self.assertEqual(result, expected) + assert result == expected def test_30_min_av_rspace(self): time_avgs = [" 30min average "] result = _calc_integration_period(time_avgs) expected = [datetime.timedelta(0, (30 * 60))] - self.assertEqual(result, expected) + assert result == expected def test_30_min_av_lstrip(self): time_avgs = [" 30min average".lstrip()] result = _calc_integration_period(time_avgs) expected = [datetime.timedelta(0, (30 * 60))] - self.assertEqual(result, expected) + assert result == expected def test_3_hour_av(self): time_avgs = [" 3hr 0min average"] result = _calc_integration_period(time_avgs) expected = [datetime.timedelta(0, (3 * 60 * 60))] - self.assertEqual(result, expected) + assert result == expected def test_3_hour_int(self): time_avgs = [" 3hr 0min integral"] result = _calc_integration_period(time_avgs) expected = [datetime.timedelta(0, (3 * 60 * 60))] - self.assertEqual(result, expected) + assert result == expected def test_12_hour_av(self): time_avgs = [" 12hr 0min average"] result = _calc_integration_period(time_avgs) expected = [datetime.timedelta(0, (12 * 60 * 60))] - self.assertEqual(result, expected) + assert result == expected def test_5_day_av(self): time_avgs = [" 5day 0hr 0min integral"] result = _calc_integration_period(time_avgs) expected = [datetime.timedelta(0, (5 * 24 * 60 * 60))] - self.assertEqual(result, expected) - - -if __name__ == "__main__": - tests.main() + assert result == expected diff --git a/lib/iris/tests/unit/fileformats/name_loaders/test__cf_height_from_name.py b/lib/iris/tests/unit/fileformats/name_loaders/test__cf_height_from_name.py index 86729ef024..f2fd376614 100644 --- a/lib/iris/tests/unit/fileformats/name_loaders/test__cf_height_from_name.py +++ b/lib/iris/tests/unit/fileformats/name_loaders/test__cf_height_from_name.py @@ -6,32 +6,26 @@ function. """ - -# Import iris.tests first so that some things can be initialised before -# importing anything else. -import iris.tests as tests # isort:skip - import numpy as np from iris.coords import AuxCoord from iris.fileformats.name_loaders import _cf_height_from_name -class TestAll(tests.IrisTest): - def _default_coord(self, data): - # This private method returns a coordinate with values expected - # when no interpretation is made of the field header string. - return AuxCoord( - units="no-unit", - points=data, - bounds=None, - standard_name=None, - long_name="z", - attributes={"positive": "up"}, - ) +def _default_coord(data): + # This private method returns a coordinate with values expected + # when no interpretation is made of the field header string. + return AuxCoord( + units="no-unit", + points=data, + bounds=None, + standard_name=None, + long_name="z", + attributes={"positive": "up"}, + ) -class TestAll_NAMEII(TestAll): +class TestAll_NAMEII: # NAMEII formats are defined by bounds, not points def test_bounded_height_above_ground(self): data = "From 0 - 100m agl" @@ -44,7 +38,7 @@ def test_bounded_height_above_ground(self): long_name="height above ground level", attributes={"positive": "up"}, ) - self.assertEqual(com, res) + assert com == res def test_bounded_flight_level(self): data = "From FL0 - FL100" @@ -57,7 +51,7 @@ def test_bounded_flight_level(self): long_name="flight_level", attributes={"positive": "up"}, ) - self.assertEqual(com, res) + assert com == res def test_bounded_height_above_sea_level(self): data = "From 0 - 100m asl" @@ -70,31 +64,31 @@ def test_bounded_height_above_sea_level(self): long_name="altitude above sea level", attributes={"positive": "up"}, ) - self.assertEqual(com, res) + assert com == res def test_malformed_height_above_ground(self): # Parse height above ground level with additional stuff on the end of # the string (agl). data = "From 0 - 100m agl and stuff" res = _cf_height_from_name(data) - com = self._default_coord(data) - self.assertEqual(com, res) + com = _default_coord(data) + assert com == res def test_malformed_height_above_sea_level(self): # Parse height above ground level with additional stuff on the end of # the string (agl). data = "From 0 - 100m asl and stuff" res = _cf_height_from_name(data) - com = self._default_coord(data) - self.assertEqual(com, res) + com = _default_coord(data) + assert com == res def test_malformed_flight_level(self): # Parse height above ground level with additional stuff on the end of # the string (agl). data = "From FL0 - FL100 and stuff" res = _cf_height_from_name(data) - com = self._default_coord(data) - self.assertEqual(com, res) + com = _default_coord(data) + assert com == res def test_float_bounded_height_above_ground(self): # Parse height above ground level when its a float. @@ -108,7 +102,7 @@ def test_float_bounded_height_above_ground(self): long_name="height above ground level", attributes={"positive": "up"}, ) - self.assertEqual(com, res) + assert com == res def test_float_bounded_height_flight_level(self): # Parse height above ground level, as a float (agl). @@ -122,7 +116,7 @@ def test_float_bounded_height_flight_level(self): long_name="flight_level", attributes={"positive": "up"}, ) - self.assertEqual(com, res) + assert com == res def test_float_bounded_height_above_sea_level(self): # Parse height above ground level as a float (agl). @@ -136,15 +130,15 @@ def test_float_bounded_height_above_sea_level(self): long_name="altitude above sea level", attributes={"positive": "up"}, ) - self.assertEqual(com, res) + assert com == res def test_no_match(self): # Parse height information when there is no match. # No interpretation, just returns default values. data = "Vertical integral" res = _cf_height_from_name(data) - com = self._default_coord(data) - self.assertEqual(com, res) + com = _default_coord(data) + assert com == res def test_pressure(self): # Parse air_pressure string. @@ -158,10 +152,10 @@ def test_pressure(self): long_name=None, attributes={"positive": "up"}, ) - self.assertEqual(com, res) + assert com == res -class TestAll_NAMEIII(TestAll): +class TestAll_NAMEIII: # NAMEIII formats are defined by points, not bounds. def test_height_above_ground(self): data = "Z = 50.00000 m agl" @@ -174,7 +168,7 @@ def test_height_above_ground(self): long_name="height above ground level", attributes={"positive": "up"}, ) - self.assertEqual(com, res) + assert com == res def test_height_flight_level(self): data = "Z = 50.00000 FL" @@ -187,7 +181,7 @@ def test_height_flight_level(self): long_name="flight_level", attributes={"positive": "up"}, ) - self.assertEqual(com, res) + assert com == res def test_height_above_sea_level(self): data = "Z = 50.00000 m asl" @@ -200,31 +194,31 @@ def test_height_above_sea_level(self): long_name="altitude above sea level", attributes={"positive": "up"}, ) - self.assertEqual(com, res) + assert com == res def test_malformed_height_above_ground(self): # Parse height above ground level, with additional stuff at the string # end (agl). data = "Z = 50.00000 m agl and stuff" res = _cf_height_from_name(data) - com = self._default_coord(data) - self.assertEqual(com, res) + com = _default_coord(data) + assert com == res def test_malformed_height_above_sea_level(self): # Parse height above ground level, with additional stuff at string # end (agl). data = "Z = 50.00000 m asl and stuff" res = _cf_height_from_name(data) - com = self._default_coord(data) - self.assertEqual(com, res) + com = _default_coord(data) + assert com == res def test_malformed_flight_level(self): # Parse height above ground level (agl), with additional stuff at # string end. data = "Z = 50.00000 FL and stuff" res = _cf_height_from_name(data) - com = self._default_coord(data) - self.assertEqual(com, res) + com = _default_coord(data) + assert com == res def test_integer_height_above_ground(self): # Parse height above ground level when its an integer. @@ -238,7 +232,7 @@ def test_integer_height_above_ground(self): long_name="height above ground level", attributes={"positive": "up"}, ) - self.assertEqual(com, res) + assert com == res def test_integer_height_flight_level(self): # Parse flight level when its an integer. @@ -252,7 +246,7 @@ def test_integer_height_flight_level(self): long_name="flight_level", attributes={"positive": "up"}, ) - self.assertEqual(com, res) + assert com == res def test_integer_height_above_sea_level(self): # Parse height above sea level (asl) when its an integer. @@ -266,7 +260,7 @@ def test_integer_height_above_sea_level(self): long_name="altitude above sea level", attributes={"positive": "up"}, ) - self.assertEqual(com, res) + assert com == res def test_enotation_height_above_ground(self): # Parse height above ground expressed in scientific notation @@ -280,7 +274,7 @@ def test_enotation_height_above_ground(self): long_name="height above ground level", attributes={"positive": "up"}, ) - self.assertEqual(com, res) + assert com == res def test_enotation_height_above_sea_level(self): # Parse height above sea level expressed in scientific notation @@ -294,7 +288,7 @@ def test_enotation_height_above_sea_level(self): long_name="altitude above sea level", attributes={"positive": "up"}, ) - self.assertEqual(com, res) + assert com == res def test_pressure(self): # Parse pressure. @@ -308,8 +302,4 @@ def test_pressure(self): long_name=None, attributes={"positive": "up"}, ) - self.assertEqual(com, res) - - -if __name__ == "__main__": - tests.main() + assert com == res diff --git a/lib/iris/tests/unit/fileformats/name_loaders/test__generate_cubes.py b/lib/iris/tests/unit/fileformats/name_loaders/test__generate_cubes.py index fc00db9663..df0c1ce08d 100644 --- a/lib/iris/tests/unit/fileformats/name_loaders/test__generate_cubes.py +++ b/lib/iris/tests/unit/fileformats/name_loaders/test__generate_cubes.py @@ -3,21 +3,17 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Unit tests for :func:`iris.analysis.name_loaders._generate_cubes`.""" - -# Import iris.tests first so that some things can be initialised before -# importing anything else. -import iris.tests as tests # isort:skip - from datetime import datetime, timedelta from unittest import mock import numpy as np from iris.fileformats.name_loaders import NAMECoord, _generate_cubes +from iris.tests._shared_utils import assert_array_equal -class TestCellMethods(tests.IrisTest): - def test_cell_methods(self): +class TestCellMethods: + def test_cell_methods(self, mocker): header = mock.MagicMock() column_headings = { "Species": [1, 2, 3], @@ -29,8 +25,8 @@ def test_cell_methods(self): data_arrays = [mock.Mock(), mock.Mock()] cell_methods = ["cell_method_1", "cell_method_2"] - self.patch("iris.fileformats.name_loaders._cf_height_from_name") - self.patch("iris.cube.Cube") + mocker.patch("iris.fileformats.name_loaders._cf_height_from_name") + mocker.patch("iris.cube.Cube") cubes = list( _generate_cubes(header, column_headings, coords, data_arrays, cell_methods) ) @@ -39,8 +35,9 @@ def test_cell_methods(self): cubes[1].assert_has_calls([mock.call.add_cell_method("cell_method_2")]) -class TestCircularLongitudes(tests.IrisTest): - def _simulate_with_coords(self, names, values, dimensions): +class TestCircularLongitudes: + @staticmethod + def _simulate_with_coords(mocker, names, values, dimensions): header = mock.MagicMock() column_headings = { "Species": [1, 2, 3], @@ -54,50 +51,53 @@ def _simulate_with_coords(self, names, values, dimensions): ] data_arrays = [mock.Mock()] - self.patch("iris.fileformats.name_loaders._cf_height_from_name") - self.patch("iris.cube.Cube") + mocker.patch("iris.fileformats.name_loaders._cf_height_from_name") + mocker.patch("iris.cube.Cube") cubes = list(_generate_cubes(header, column_headings, coords, data_arrays)) return cubes - def test_non_circular(self): + def test_non_circular(self, mocker): results = self._simulate_with_coords( - names=["longitude"], values=[[1, 7, 23]], dimensions=[0] + mocker, names=["longitude"], values=[[1, 7, 23]], dimensions=[0] ) - self.assertEqual(len(results), 1) + assert len(results) == 1 add_coord_calls = results[0].add_dim_coord.call_args_list - self.assertEqual(len(add_coord_calls), 1) + assert len(add_coord_calls) == 1 coord = add_coord_calls[0][0][0] - self.assertEqual(coord.circular, False) + assert coord.circular is False - def test_circular(self): + def test_circular(self, mocker): results = self._simulate_with_coords( + mocker, names=["longitude"], values=[[5.0, 95.0, 185.0, 275.0]], dimensions=[0], ) - self.assertEqual(len(results), 1) + assert len(results) == 1 add_coord_calls = results[0].add_dim_coord.call_args_list - self.assertEqual(len(add_coord_calls), 1) + assert len(add_coord_calls) == 1 coord = add_coord_calls[0][0][0] - self.assertEqual(coord.circular, True) + assert coord.circular is True - def test_lat_lon_byname(self): + def test_lat_lon_byname(self, mocker): results = self._simulate_with_coords( + mocker, names=["longitude", "latitude"], values=[[5.0, 95.0, 185.0, 275.0], [5.0, 95.0, 185.0, 275.0]], dimensions=[0, 1], ) - self.assertEqual(len(results), 1) + assert len(results) == 1 add_coord_calls = results[0].add_dim_coord.call_args_list - self.assertEqual(len(add_coord_calls), 2) + assert len(add_coord_calls) == 2 lon_coord = add_coord_calls[0][0][0] lat_coord = add_coord_calls[1][0][0] - self.assertEqual(lon_coord.circular, True) - self.assertEqual(lat_coord.circular, False) + assert lon_coord.circular is True + assert lat_coord.circular is False -class TestTimeCoord(tests.IrisTest): - def _simulate_with_coords(self, names, values, dimensions): +class TestTimeCoord: + @staticmethod + def _simulate_with_coords(mocker, names, values, dimensions): header = mock.MagicMock() column_headings = { "Species": [1, 2, 3], @@ -111,13 +111,14 @@ def _simulate_with_coords(self, names, values, dimensions): ] data_arrays = [mock.Mock()] - self.patch("iris.fileformats.name_loaders._cf_height_from_name") - self.patch("iris.cube.Cube") + mocker.patch("iris.fileformats.name_loaders._cf_height_from_name") + mocker.patch("iris.cube.Cube") cubes = list(_generate_cubes(header, column_headings, coords, data_arrays)) return cubes - def test_time_dim(self): + def test_time_dim(self, mocker): results = self._simulate_with_coords( + mocker, names=["longitude", "latitude", "time"], values=[ [10, 20], @@ -126,33 +127,30 @@ def test_time_dim(self): ], dimensions=[0, 1, 2], ) - self.assertEqual(len(results), 1) + assert len(results) == 1 result = results[0] dim_coord_calls = result.add_dim_coord.call_args_list - self.assertEqual(len(dim_coord_calls), 3) # lon, lat, time + assert len(dim_coord_calls) == 3 # lon, lat, time t_coord = dim_coord_calls[2][0][0] - self.assertEqual(t_coord.standard_name, "time") - self.assertArrayEqual(t_coord.points, [398232, 398256]) - self.assertArrayEqual(t_coord.bounds[0], [398208, 398232]) - self.assertArrayEqual(t_coord.bounds[-1], [398232, 398256]) + assert t_coord.standard_name == "time" + assert_array_equal(t_coord.points, [398232, 398256]) + assert_array_equal(t_coord.bounds[0], [398208, 398232]) + assert_array_equal(t_coord.bounds[-1], [398232, 398256]) - def test_time_scalar(self): + def test_time_scalar(self, mocker): results = self._simulate_with_coords( + mocker, names=["longitude", "latitude", "time"], values=[[10, 20], [30, 40], [datetime(2015, 6, 7)]], dimensions=[0, 1, None], ) - self.assertEqual(len(results), 1) + assert len(results) == 1 result = results[0] dim_coord_calls = result.add_dim_coord.call_args_list - self.assertEqual(len(dim_coord_calls), 2) + assert len(dim_coord_calls) == 2 aux_coord_calls = result.add_aux_coord.call_args_list - self.assertEqual(len(aux_coord_calls), 1) + assert len(aux_coord_calls) == 1 t_coord = aux_coord_calls[0][0][0] - self.assertEqual(t_coord.standard_name, "time") - self.assertArrayEqual(t_coord.points, [398232]) - self.assertArrayEqual(t_coord.bounds, [[398208, 398232]]) - - -if __name__ == "__main__": - tests.main() + assert t_coord.standard_name == "time" + assert_array_equal(t_coord.points, [398232]) + assert_array_equal(t_coord.bounds, [[398208, 398232]])