From e69ec5dfd9e1d917e6426bf1ab21d3551d00857d Mon Sep 17 00:00:00 2001 From: Bouwe Andela Date: Wed, 16 Oct 2024 16:08:53 +0200 Subject: [PATCH] Enable ruff pydocstyle linter rule (#2547) Co-authored-by: Manuel Schlund <32543114+schlunma@users.noreply.github.com> --- esmvalcore/cmor/_fixes/__init__.py | 2 +- esmvalcore/cmor/_fixes/cmip5/gfdl_cm3.py | 4 +- esmvalcore/cmor/_fixes/cmip5/gfdl_esm2g.py | 4 +- esmvalcore/cmor/_fixes/cmip5/gfdl_esm2m.py | 2 +- pyproject.toml | 10 ++ tests/__init__.py | 6 +- tests/conftest.py | 2 +- .../cmor/_fixes/cmip5/test_bnu_esm.py | 2 +- .../cmor/_fixes/cmip5/test_cnrm_cm5.py | 4 +- .../cmor/_fixes/cmip5/test_ec_earth.py | 16 +- .../cmor/_fixes/cmip5/test_fio_esm.py | 4 +- .../cmor/_fixes/cmip5/test_gfdl_cm2p1.py | 6 +- .../cmor/_fixes/cmip5/test_gfdl_cm3.py | 4 +- .../cmor/_fixes/cmip5/test_gfdl_esm2g.py | 8 +- .../cmor/_fixes/cmip5/test_gfdl_esm2m.py | 6 +- .../cmor/_fixes/cmip5/test_hadgem2_cc.py | 4 +- .../cmor/_fixes/cmip5/test_miroc_esm_chem.py | 2 +- .../cmor/_fixes/cmip5/test_mri_esm1.py | 2 +- .../cmor/_fixes/cmip5/test_noresm1_me.py | 2 +- .../integration/cmor/_fixes/icon/test_icon.py | 4 +- .../cmor/_fixes/ipslcm/test_ipsl_cm6.py | 1 - tests/integration/cmor/_fixes/test_common.py | 1 - .../cmor/_fixes/test_data/create_test_data.py | 2 +- tests/integration/cmor/test_fix.py | 2 +- .../preprocessor/_derive/test_sithick.py | 2 - .../integration/preprocessor/_io/test_save.py | 2 +- .../preprocessor/_mask/__init__.py | 2 +- .../preprocessor/_regrid/__init__.py | 5 +- .../_regrid/test_extract_coordinate_points.py | 25 ++- .../_regrid/test_extract_levels.py | 3 +- .../_regrid/test_extract_location.py | 10 +- .../_regrid/test_extract_point.py | 26 ++- .../_regrid/test_get_cmor_levels.py | 7 +- .../_regrid/test_get_file_levels.py | 3 +- .../preprocessor/_regrid/test_regrid.py | 6 +- .../_regrid/test_regrid_schemes.py | 4 +- .../_supplementary_vars/test_register.py | 2 +- tests/integration/recipe/test_recipe.py | 2 - tests/integration/test_task.py | 2 +- tests/unit/cmor/test_cmor_check.py | 170 +++++++++++------- tests/unit/cmor/test_generic_fix.py | 2 +- tests/unit/config/test_config_object.py | 2 +- tests/unit/experimental/test_recipe_output.py | 4 - tests/unit/local/test_select_files.py | 6 +- tests/unit/local/test_time.py | 18 +- tests/unit/preprocessor/_area/test_area.py | 6 +- .../test_compare_with_refs.py | 2 +- tests/unit/preprocessor/_mask/test_mask.py | 2 +- tests/unit/preprocessor/_regrid/__init__.py | 15 +- .../preprocessor/_regrid/test__create_cube.py | 6 +- .../preprocessor/_regrid/test__stock_cube.py | 6 +- .../_regrid/test_extract_point.py | 6 +- .../_regrid/test_extract_regional_grid.py | 2 +- .../unit/preprocessor/_regrid/test_regrid.py | 23 ++- tests/unit/preprocessor/_time/test_time.py | 8 +- .../unit/preprocessor/_volume/test_volume.py | 31 ++-- tests/unit/preprocessor/test_shared.py | 2 +- tests/unit/recipe/test_recipe.py | 2 +- tests/unit/test_naming.py | 12 +- 59 files changed, 264 insertions(+), 262 deletions(-) diff --git a/esmvalcore/cmor/_fixes/__init__.py b/esmvalcore/cmor/_fixes/__init__.py index e50e749659..4327b12471 100644 --- a/esmvalcore/cmor/_fixes/__init__.py +++ b/esmvalcore/cmor/_fixes/__init__.py @@ -1,5 +1,5 @@ """ -Automatic fixes for input data +Automatic fixes for input data. Module to apply automatic fixes at different levels to input data for known errors. diff --git a/esmvalcore/cmor/_fixes/cmip5/gfdl_cm3.py b/esmvalcore/cmor/_fixes/cmip5/gfdl_cm3.py index f2cf4b7101..3938d20e0a 100644 --- a/esmvalcore/cmor/_fixes/cmip5/gfdl_cm3.py +++ b/esmvalcore/cmor/_fixes/cmip5/gfdl_cm3.py @@ -9,7 +9,7 @@ class AllVars(BaseAllVars): class Areacello(Fix): - """Fixes for areacello""" + """Fixes for areacello.""" def fix_metadata(self, cubes): """ @@ -56,7 +56,7 @@ def fix_data(self, cube): class Tos(Fix): - """Fixes for tos""" + """Fixes for tos.""" def fix_metadata(self, cubes): """ diff --git a/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2g.py b/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2g.py index f3722c9d07..cf199a3229 100644 --- a/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2g.py +++ b/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2g.py @@ -37,7 +37,7 @@ def fix_metadata(self, cubes): class Areacello(Fix): - """Fixes for areacello""" + """Fixes for areacello.""" def fix_metadata(self, cubes): """ @@ -116,6 +116,7 @@ def fix_metadata(self, cubes): Parameters ---------- cubes: iris.cube.CubeList + Returns ------- iris.cube.CubeList @@ -137,6 +138,7 @@ def fix_metadata(self, cubes): Parameters ---------- cubes: iris.cube.CubeList + Returns ------- iris.cube.CubeList diff --git a/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2m.py b/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2m.py index e358bf525c..e7993c8903 100644 --- a/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2m.py +++ b/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2m.py @@ -9,7 +9,7 @@ class AllVars(BaseAllVars): class Areacello(Fix): - """Fixes for areacello""" + """Fixes for areacello.""" def fix_metadata(self, cubes): """ diff --git a/pyproject.toml b/pyproject.toml index 5abbbaa1d1..6234370689 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,6 +34,7 @@ line-length = 79 [tool.ruff.lint] select = [ "B", + "D", # pydocstyle "E", # pycodestyle "F", # pyflakes "I", # isort @@ -42,10 +43,19 @@ select = [ ] ignore = [ "E501", # Disable line-too-long as this is taken care of by the formatter. + "D105", # Disable Missing docstring in magic method as these are well defined. ] [tool.ruff.lint.per-file-ignores] "tests/**.py" = [ "B011", # `assert False` is valid test code. + # Docstrings in tests are only needed if the code is not self-explanatory. + "D100", # Missing docstring in public module + "D101", # Missing docstring in public class + "D102", # Missing docstring in public method + "D103", # Missing docstring in public function + "D104", # Missing docstring in public package ] [tool.ruff.lint.isort] known-first-party = ["esmvalcore"] +[tool.ruff.lint.pydocstyle] +convention = "numpy" diff --git a/tests/__init__.py b/tests/__init__.py index 7c55516496..e24d27357e 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -19,11 +19,7 @@ class Test(unittest.TestCase): """Provides esmvaltool specific testing functionality.""" def _remove_testcase_patches(self): - """ - Helper method to remove per-testcase patches installed by - :meth:`patch`. - - """ + """Remove per-testcase patches installed by :meth:`patch`.""" # Remove all patches made, ignoring errors. for patch in self.testcase_patches: patch.stop() diff --git a/tests/conftest.py b/tests/conftest.py index 0d385fb2f4..d973b76695 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -8,7 +8,7 @@ @pytest.fixture def cfg_default(mocker): - """Configuration object with defaults.""" + """Create a configuration object with default values.""" cfg = deepcopy(CFG) cfg.load_from_dirs([]) return cfg diff --git a/tests/integration/cmor/_fixes/cmip5/test_bnu_esm.py b/tests/integration/cmor/_fixes/cmip5/test_bnu_esm.py index a48dd9860b..1921282378 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_bnu_esm.py +++ b/tests/integration/cmor/_fixes/cmip5/test_bnu_esm.py @@ -29,7 +29,7 @@ def setUp(self): self.fix = Cl(None) def test_get(self): - """Test fix get""" + """Test fix get.""" fix = Fix.get_fixes("CMIP5", "BNU-ESM", "Amon", "cl") assert fix == [Cl(None), GenericFix(None)] diff --git a/tests/integration/cmor/_fixes/cmip5/test_cnrm_cm5.py b/tests/integration/cmor/_fixes/cmip5/test_cnrm_cm5.py index cc7c9a8059..12cdf8fd53 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_cnrm_cm5.py +++ b/tests/integration/cmor/_fixes/cmip5/test_cnrm_cm5.py @@ -19,7 +19,7 @@ def setUp(self): self.fix = Msftmyz(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes("CMIP5", "CNRM-CM5", "Amon", "msftmyz"), [Msftmyz(None), GenericFix(None)], @@ -41,7 +41,7 @@ def setUp(self): self.fix = Msftmyzba(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes("CMIP5", "CNRM-CM5", "Amon", "msftmyzba"), [Msftmyzba(None), GenericFix(None)], diff --git a/tests/integration/cmor/_fixes/cmip5/test_ec_earth.py b/tests/integration/cmor/_fixes/cmip5/test_ec_earth.py index 9fdd838268..8390e9385b 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_ec_earth.py +++ b/tests/integration/cmor/_fixes/cmip5/test_ec_earth.py @@ -28,7 +28,7 @@ def setUp(self): self.fix = Sic(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes("CMIP5", "EC-EARTH", "Amon", "sic"), [Sic(None), GenericFix(None)], @@ -50,7 +50,7 @@ def setUp(self): self.fix = Sftlf(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes("CMIP5", "EC-EARTH", "Amon", "sftlf"), [Sftlf(None), GenericFix(None)], @@ -68,7 +68,6 @@ class TestTas(unittest.TestCase): def setUp(self): """Prepare tests.""" - height_coord = DimCoord( 2.0, standard_name="height", @@ -99,7 +98,7 @@ def setUp(self): self.fix = Tas(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes("CMIP5", "EC-EARTH", "Amon", "tas"), [Tas(None), GenericFix(None)], @@ -107,7 +106,6 @@ def test_get(self): def test_tas_fix_metadata(self): """Test metadata fix.""" - out_cube_without = self.fix.fix_metadata(self.cube_without) # make sure this does not raise an error @@ -131,7 +129,6 @@ class TestAreacello(unittest.TestCase): def setUp(self): """Prepare tests.""" - latitude = Cube( np.ones((2, 2)), standard_name="latitude", @@ -163,7 +160,7 @@ def setUp(self): self.fix = Areacello(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes("CMIP5", "EC-EARTH", "Omon", "areacello"), [Areacello(None), GenericFix(None)], @@ -171,7 +168,6 @@ def test_get(self): def test_areacello_fix_metadata(self): """Test metadata fix.""" - out_cube = self.fix.fix_metadata(self.cubes) assert len(out_cube) == 1 @@ -184,7 +180,6 @@ class TestPr(unittest.TestCase): def setUp(self): """Prepare tests.""" - wrong_time_coord = AuxCoord( points=[1.0, 2.0, 1.0, 2.0, 3.0], var_name="time", @@ -226,7 +221,7 @@ def setUp(self): self.fix = Pr(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes("CMIP5", "EC-EARTH", "Amon", "pr"), [Pr(None), GenericFix(None)], @@ -234,7 +229,6 @@ def test_get(self): def test_pr_fix_metadata(self): """Test metadata fix.""" - out_wrong_cube = self.fix.fix_metadata(self.wrong_cube) out_correct_cube = self.fix.fix_metadata(self.correct_cube) diff --git a/tests/integration/cmor/_fixes/cmip5/test_fio_esm.py b/tests/integration/cmor/_fixes/cmip5/test_fio_esm.py index 2da5fd742f..a9d582f98d 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_fio_esm.py +++ b/tests/integration/cmor/_fixes/cmip5/test_fio_esm.py @@ -31,7 +31,7 @@ def setUp(self): self.fix = Ch4(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes("CMIP5", "FIO-ESM", "Amon", "ch4"), [Ch4(None), GenericFix(None)], @@ -53,7 +53,7 @@ def setUp(self): self.fix = Co2(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes("CMIP5", "FIO-ESM", "Amon", "co2"), [Co2(None), GenericFix(None)], diff --git a/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm2p1.py b/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm2p1.py index 0ddcfdcacf..77b2521cb1 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm2p1.py +++ b/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm2p1.py @@ -44,7 +44,7 @@ def setUp(self): self.fix = Sftof(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes("CMIP5", "GFDL-CM2P1", "fx", "sftof"), [Sftof(None), AllVars(None), GenericFix(None)], @@ -67,7 +67,7 @@ def setUp(self): self.fix = Areacello(self.vardef) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes("CMIP5", "GFDL-CM2P1", "Amon", "areacello"), [ @@ -114,7 +114,7 @@ def setUp(self): self.fix = Sit(self.var_info_mock) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes("CMIP5", "GFDL-CM2P1", "OImon", "sit"), [Sit(self.var_info_mock), AllVars(None), GenericFix(None)], diff --git a/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm3.py b/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm3.py index fffe1812ee..d7647dfee1 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm3.py +++ b/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm3.py @@ -20,7 +20,7 @@ def setUp(self): self.fix = Sftof(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes("CMIP5", "GFDL-CM3", "fx", "sftof"), [Sftof(None), AllVars(None), GenericFix(None)], @@ -43,7 +43,7 @@ def setUp(self): self.fix = Areacello(self.vardef) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes("CMIP5", "GFDL-CM3", "Amon", "areacello"), [ diff --git a/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2g.py b/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2g.py index 30421411e3..967ea83a2d 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2g.py +++ b/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2g.py @@ -79,7 +79,7 @@ def setUp(self): self.fix = Co2(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes("CMIP5", "GFDL-ESM2G", "Amon", "co2"), [Co2(None), AllVars(None), GenericFix(None)], @@ -102,7 +102,7 @@ def setUp(self): self.fix = Usi(self.vardef) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes("CMIP5", "GFDL-ESM2G", "day", "usi"), [Usi(self.vardef), AllVars(self.vardef), GenericFix(self.vardef)], @@ -124,7 +124,7 @@ def setUp(self): self.fix = Vsi(self.vardef) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes("CMIP5", "GFDL-ESM2G", "day", "vsi"), [Vsi(self.vardef), AllVars(self.vardef), GenericFix(self.vardef)], @@ -146,7 +146,7 @@ def setUp(self): self.fix = Areacello(self.vardef) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes("CMIP5", "GFDL-ESM2G", "fx", "areacello"), [ diff --git a/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2m.py b/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2m.py index 29f3ba4c7e..428bc72434 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2m.py +++ b/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2m.py @@ -25,7 +25,7 @@ def setUp(self): self.fix = Sftof(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes("CMIP5", "GFDL-ESM2M", "fx", "sftof"), [Sftof(None), AllVars(None), GenericFix(None)], @@ -47,7 +47,7 @@ def setUp(self): self.fix = Co2(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes("CMIP5", "GFDL-ESM2M", "Amon", "co2"), [Co2(None), AllVars(None), GenericFix(None)], @@ -70,7 +70,7 @@ def setUp(self): self.fix = Areacello(self.vardef) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes("CMIP5", "GFDL-ESM2M", "fx", "areacello"), [ diff --git a/tests/integration/cmor/_fixes/cmip5/test_hadgem2_cc.py b/tests/integration/cmor/_fixes/cmip5/test_hadgem2_cc.py index 13642a35ad..fd9a4c1ae2 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_hadgem2_cc.py +++ b/tests/integration/cmor/_fixes/cmip5/test_hadgem2_cc.py @@ -11,7 +11,7 @@ class TestAllVars(unittest.TestCase): """Test allvars fixes.""" def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes("CMIP5", "HADGEM2-CC", "Amon", "tas"), [AllVars(None), GenericFix(None)], @@ -22,7 +22,7 @@ class TestO2(unittest.TestCase): """Test o2 fixes.""" def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes("CMIP5", "HADGEM2-CC", "Amon", "o2"), [O2(None), AllVars(None), GenericFix(None)], diff --git a/tests/integration/cmor/_fixes/cmip5/test_miroc_esm_chem.py b/tests/integration/cmor/_fixes/cmip5/test_miroc_esm_chem.py index 21624bcc44..9f97232c55 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_miroc_esm_chem.py +++ b/tests/integration/cmor/_fixes/cmip5/test_miroc_esm_chem.py @@ -19,7 +19,7 @@ def setUp(self): self.fix = Tro3(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes("CMIP5", "MIROC-ESM-CHEM", "Amon", "tro3"), [Tro3(None), GenericFix(None)], diff --git a/tests/integration/cmor/_fixes/cmip5/test_mri_esm1.py b/tests/integration/cmor/_fixes/cmip5/test_mri_esm1.py index a847a30f15..16969fc6d8 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_mri_esm1.py +++ b/tests/integration/cmor/_fixes/cmip5/test_mri_esm1.py @@ -11,7 +11,7 @@ class TestMsftmyz(unittest.TestCase): """Test msftmyz fixes.""" def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes("CMIP5", "MRI-ESM1", "Amon", "msftmyz"), [Msftmyz(None), GenericFix(None)], diff --git a/tests/integration/cmor/_fixes/cmip5/test_noresm1_me.py b/tests/integration/cmor/_fixes/cmip5/test_noresm1_me.py index 87d94760a1..bedac4aa50 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_noresm1_me.py +++ b/tests/integration/cmor/_fixes/cmip5/test_noresm1_me.py @@ -72,7 +72,7 @@ def test_tas(cubes_in, cubes_out): def test_get(): - """Test fix get""" + """Test fix get.""" assert Fix.get_fixes("CMIP5", "NORESM1-ME", "Amon", "tas") == [ Tas(None), GenericFix(None), diff --git a/tests/integration/cmor/_fixes/icon/test_icon.py b/tests/integration/cmor/_fixes/icon/test_icon.py index b87c052008..cfd3ea6726 100644 --- a/tests/integration/cmor/_fixes/icon/test_icon.py +++ b/tests/integration/cmor/_fixes/icon/test_icon.py @@ -1,4 +1,4 @@ -"""Tests for the ICON on-the-fly CMORizer.""" +"""Test the ICON on-the-fly CMORizer.""" from copy import deepcopy from datetime import datetime @@ -134,7 +134,7 @@ def cubes_2d_lat_lon_grid(): @pytest.fixture def simple_unstructured_cube(): - """Simple cube with unstructured grid.""" + """Create a cube with an unstructured grid.""" time_coord = DimCoord( [0], var_name="time", diff --git a/tests/integration/cmor/_fixes/ipslcm/test_ipsl_cm6.py b/tests/integration/cmor/_fixes/ipslcm/test_ipsl_cm6.py index f13c329d49..4b2e83784f 100644 --- a/tests/integration/cmor/_fixes/ipslcm/test_ipsl_cm6.py +++ b/tests/integration/cmor/_fixes/ipslcm/test_ipsl_cm6.py @@ -19,7 +19,6 @@ def test_get_tas_fix(): @pytest.fixture def cubes(): """``tas`` cube.""" - cube = iris.cube.Cube( [200.0], # chilly, isn't it ? var_name="tas", diff --git a/tests/integration/cmor/_fixes/test_common.py b/tests/integration/cmor/_fixes/test_common.py index 075335d7d8..781c5df0f9 100644 --- a/tests/integration/cmor/_fixes/test_common.py +++ b/tests/integration/cmor/_fixes/test_common.py @@ -305,7 +305,6 @@ def get_tos_cubes(wrong_ij_names=False, ij_bounds=False): def get_tos_regular_grid_cubes(): """Cubes containing tos variable.""" - time_coord = iris.coords.DimCoord( 1.0, bounds=[0.0, 2.0], diff --git a/tests/integration/cmor/_fixes/test_data/create_test_data.py b/tests/integration/cmor/_fixes/test_data/create_test_data.py index 35dc40351b..c4ff26ab4b 100644 --- a/tests/integration/cmor/_fixes/test_data/create_test_data.py +++ b/tests/integration/cmor/_fixes/test_data/create_test_data.py @@ -456,7 +456,7 @@ def save_gfdl_cm4_cl_file(save_path): def main(): - """Main function to create datasets.""" + """Create all datasets.""" save_path = os.path.dirname(os.path.abspath(__file__)) save_cl_file_with_a(save_path) save_cl_file_with_ap(save_path) diff --git a/tests/integration/cmor/test_fix.py b/tests/integration/cmor/test_fix.py index 74a0a08841..4af47a44d7 100644 --- a/tests/integration/cmor/test_fix.py +++ b/tests/integration/cmor/test_fix.py @@ -22,7 +22,7 @@ class TestGenericFix: @pytest.fixture(autouse=True) def setup(self, mocker): - """Setup tests.""" + """Set up tests.""" self.mock_debug = mocker.patch( "esmvalcore.cmor._fixes.fix.GenericFix._debug_msg", autospec=True ) diff --git a/tests/integration/preprocessor/_derive/test_sithick.py b/tests/integration/preprocessor/_derive/test_sithick.py index d0523d6d7d..4b59a71cf4 100644 --- a/tests/integration/preprocessor/_derive/test_sithick.py +++ b/tests/integration/preprocessor/_derive/test_sithick.py @@ -8,7 +8,6 @@ def test_sispeed_calculation(): """Test calculation of `sithick`.""" - siconc = Cube(np.full((2, 2), 0.5), "sea_ice_area_fraction", units="1.0") sivol = Cube(np.full((2, 2), 0.5), "sea_ice_thickness") @@ -20,7 +19,6 @@ def test_sispeed_calculation(): def test_sispeed_calculation_percent(): """Test calculation of `sithick` with sit in %.""" - siconc = Cube(np.full((2, 2), 50.0), "sea_ice_area_fraction", units="%") sivol = Cube(np.full((2, 2), 0.5), "sea_ice_thickness") diff --git a/tests/integration/preprocessor/_io/test_save.py b/tests/integration/preprocessor/_io/test_save.py index 0bfd0c6958..0e4f6b4366 100644 --- a/tests/integration/preprocessor/_io/test_save.py +++ b/tests/integration/preprocessor/_io/test_save.py @@ -1,4 +1,4 @@ -"""Integration tests for :func:`esmvalcore.preprocessor.save`""" +"""Integration tests for :func:`esmvalcore.preprocessor.save`.""" import iris import netCDF4 diff --git a/tests/integration/preprocessor/_mask/__init__.py b/tests/integration/preprocessor/_mask/__init__.py index 9886ea9eed..97e5350864 100644 --- a/tests/integration/preprocessor/_mask/__init__.py +++ b/tests/integration/preprocessor/_mask/__init__.py @@ -1,5 +1,5 @@ """ -Test _mask.py +Test _mask.py. Integration tests for the esmvalcore.preprocessor._mask module """ diff --git a/tests/integration/preprocessor/_regrid/__init__.py b/tests/integration/preprocessor/_regrid/__init__.py index e19e118a0f..bb8eab5e54 100644 --- a/tests/integration/preprocessor/_regrid/__init__.py +++ b/tests/integration/preprocessor/_regrid/__init__.py @@ -1,4 +1 @@ -""" -Integration tests for the :mod:`esmvalcore.preprocessor._regrid` module. - -""" +"""Integration tests for the :mod:`esmvalcore.preprocessor._regrid` module.""" diff --git a/tests/integration/preprocessor/_regrid/test_extract_coordinate_points.py b/tests/integration/preprocessor/_regrid/test_extract_coordinate_points.py index d5cad7c9ec..1cf039b7b4 100644 --- a/tests/integration/preprocessor/_regrid/test_extract_coordinate_points.py +++ b/tests/integration/preprocessor/_regrid/test_extract_coordinate_points.py @@ -1,8 +1,4 @@ -""" -Integration tests for the :func:`esmvalcore.preprocessor.regrid.regrid` -function. - -""" +"""Integration tests for :func:`esmvalcore.preprocessor.regrid`.""" import unittest @@ -23,7 +19,7 @@ def setUp(self): self.cs = iris.coord_systems.GeogCS(iris.fileformats.pp.EARTH_RADIUS) def test_extract_point__single_linear(self): - """Test linear interpolation when extracting a single point""" + """Test linear interpolation when extracting a single point.""" point = extract_coordinate_points( self.cube, {"grid_latitude": 2.1, "grid_longitude": 2.1}, @@ -71,8 +67,7 @@ def test_extract_point__single_linear(self): self.assert_array_equal(point.data, masked) def test_extract_point__single_nearest(self): - """Test nearest match when extracting a single point""" - + """Test nearest match when extracting a single point.""" point = extract_coordinate_points( self.cube, {"grid_latitude": 2.1, "grid_longitude": 2.1}, @@ -108,8 +103,7 @@ def test_extract_point__single_nearest(self): self.assert_array_equal(point.data, masked) def test_extract_point__multiple_linear(self): - """Test linear interpolation for an array of one coordinate""" - + """Test linear interpolation for an array of one coordinate.""" # Test points on the grid edges, on a grid point, halfway and # one in between. coords = self.cube.coords(dim_coords=True) @@ -176,8 +170,7 @@ def test_extract_point__multiple_linear(self): self.assert_array_equal(point.data, masked) def test_extract_point__multiple_nearest(self): - """Test nearest match for an array of one coordinate""" - + """Test nearest match for an array of one coordinate.""" point = extract_coordinate_points( self.cube, {"grid_latitude": [1, 1.1, 1.5, 1.501, 2, 4], "grid_longitude": 2}, @@ -231,8 +224,10 @@ def test_extract_point__multiple_nearest(self): self.assert_array_equal(point.data, masked) def test_extract_point__multiple_both_linear(self): - """Test for both latitude and longitude arrays, with - linear interpolation""" + """Test for both latitude and longitude arrays. + + With linear interpolation. + """ point = extract_coordinate_points( self.cube, { @@ -266,7 +261,7 @@ def test_extract_point__multiple_both_linear(self): np.testing.assert_allclose(point.data, result) def test_extract_point__multiple_both_nearest(self): - """Test for both latitude and longitude arrays, with nearest match""" + """Test for both latitude and longitude arrays, with nearest match.""" point = extract_coordinate_points( self.cube, { diff --git a/tests/integration/preprocessor/_regrid/test_extract_levels.py b/tests/integration/preprocessor/_regrid/test_extract_levels.py index 000931637d..82c9991a64 100644 --- a/tests/integration/preprocessor/_regrid/test_extract_levels.py +++ b/tests/integration/preprocessor/_regrid/test_extract_levels.py @@ -1,5 +1,4 @@ -"""Integration tests for the -:func:`esmvalcore.preprocessor.regrid.extract_levels` function.""" +"""Tests for :func:`esmvalcore.preprocessor.regrid.extract_levels` function.""" import unittest diff --git a/tests/integration/preprocessor/_regrid/test_extract_location.py b/tests/integration/preprocessor/_regrid/test_extract_location.py index b5c316bd39..3b3274fb82 100644 --- a/tests/integration/preprocessor/_regrid/test_extract_location.py +++ b/tests/integration/preprocessor/_regrid/test_extract_location.py @@ -117,10 +117,12 @@ def test_no_scheme_parameter(test_cube): @patch("esmvalcore.preprocessor._regrid.ssl.create_default_context") def test_create_default_ssl_context_raises_exception(mock_create, test_cube): - """Test the original way 'extract_location' worked before adding the - default SSL context, see - https://github.com/ESMValGroup/ESMValCore/issues/2012 for more - information.""" + """Test the original way 'extract_location' worked. + + Test the way `extract_location` worked before adding the default SSL + context, see https://github.com/ESMValGroup/ESMValCore/issues/2012 for more + information. + """ mock_create.side_effect = ssl.SSLSyscallError extract_location(test_cube, scheme="nearest", location="Peñacaballera") mock_create.assert_called_once() diff --git a/tests/integration/preprocessor/_regrid/test_extract_point.py b/tests/integration/preprocessor/_regrid/test_extract_point.py index 132d3fb8dd..dc139bd8d7 100644 --- a/tests/integration/preprocessor/_regrid/test_extract_point.py +++ b/tests/integration/preprocessor/_regrid/test_extract_point.py @@ -1,8 +1,4 @@ -""" -Integration tests for the :func:`esmvalcore.preprocessor.regrid.regrid` -function. - -""" +"""Integration tests for :func:`esmvalcore.preprocessor.regrid`.""" import unittest @@ -23,8 +19,7 @@ def setUp(self): self.cs = iris.coord_systems.GeogCS(iris.fileformats.pp.EARTH_RADIUS) def test_extract_point__single_linear(self): - """Test linear interpolation when extracting a single point""" - + """Test linear interpolation when extracting a single point.""" point = extract_point(self.cube, 2.1, 2.1, scheme="linear") self.assertEqual(point.shape, (3,)) np.testing.assert_allclose(point.data, [5.5, 21.5, 37.5]) @@ -58,8 +53,7 @@ def test_extract_point__single_linear(self): assert point.data.mask.all() def test_extract_point__single_nearest(self): - """Test nearest match when extracting a single point""" - + """Test nearest match when extracting a single point.""" point = extract_point(self.cube, 2.1, 2.1, scheme="nearest") self.assertEqual(point.shape, (3,)) np.testing.assert_allclose(point.data, [5, 21, 37]) @@ -79,8 +73,7 @@ def test_extract_point__single_nearest(self): self.assert_array_equal(point.data, masked) def test_extract_point__multiple_linear(self): - """Test linear interpolation for an array of one coordinate""" - + """Test linear interpolation for an array of one coordinate.""" # Test points on the grid edges, on a grid point, halfway and # one in between. coords = self.cube.coords(dim_coords=True) @@ -135,8 +128,7 @@ def test_extract_point__multiple_linear(self): self.assert_array_equal(point.data, masked) def test_extract_point__multiple_nearest(self): - """Test nearest match for an array of one coordinate""" - + """Test nearest match for an array of one coordinate.""" point = extract_point( self.cube, [1, 1.1, 1.5, 1.501, 2, 4], 2, scheme="nearest" ) @@ -178,8 +170,10 @@ def test_extract_point__multiple_nearest(self): self.assert_array_equal(point.data, masked) def test_extract_point__multiple_both_linear(self): - """Test for both latitude and longitude arrays, with - linear interpolation""" + """Test for both latitude and longitude arrays. + + Uses linear interpolation. + """ point = extract_point( self.cube, [0, 1.1, 1.5, 1.51, 4, 5], @@ -211,7 +205,7 @@ def test_extract_point__multiple_both_linear(self): np.testing.assert_allclose(point.data, result) def test_extract_point__multiple_both_nearest(self): - """Test for both latitude and longitude arrays, with nearest match""" + """Test for both latitude and longitude arrays, with nearest match.""" point = extract_point( self.cube, [0, 1.1, 1.5, 1.51, 4, 5], diff --git a/tests/integration/preprocessor/_regrid/test_get_cmor_levels.py b/tests/integration/preprocessor/_regrid/test_get_cmor_levels.py index af18135070..e2c14c39fd 100644 --- a/tests/integration/preprocessor/_regrid/test_get_cmor_levels.py +++ b/tests/integration/preprocessor/_regrid/test_get_cmor_levels.py @@ -1,9 +1,4 @@ -""" -Integration tests for the :func: -`esmvalcore.preprocessor.regrid.get_cmor_levels` -function. - -""" +"""Tests for :func:`esmvalcore.preprocessor.regrid.get_cmor_levels`.""" import unittest diff --git a/tests/integration/preprocessor/_regrid/test_get_file_levels.py b/tests/integration/preprocessor/_regrid/test_get_file_levels.py index ed5069e2a9..3421fb8939 100644 --- a/tests/integration/preprocessor/_regrid/test_get_file_levels.py +++ b/tests/integration/preprocessor/_regrid/test_get_file_levels.py @@ -1,5 +1,4 @@ -"""Integration test for -:func:`esmvalcore.preprocessor.regrid.get_reference_levels`.""" +"""Tests for :func:`esmvalcore.preprocessor.regrid.get_reference_levels`.""" import iris.coords import iris.cube diff --git a/tests/integration/preprocessor/_regrid/test_regrid.py b/tests/integration/preprocessor/_regrid/test_regrid.py index bf39ee9ff2..05f6a475db 100644 --- a/tests/integration/preprocessor/_regrid/test_regrid.py +++ b/tests/integration/preprocessor/_regrid/test_regrid.py @@ -1,8 +1,4 @@ -""" -Integration tests for the :func:`esmvalcore.preprocessor.regrid.regrid` -function. - -""" +"""Integration tests for :func:`esmvalcore.preprocessor.regrid`.""" import iris import numpy as np diff --git a/tests/integration/preprocessor/_regrid/test_regrid_schemes.py b/tests/integration/preprocessor/_regrid/test_regrid_schemes.py index 2685d33207..6e548238d1 100644 --- a/tests/integration/preprocessor/_regrid/test_regrid_schemes.py +++ b/tests/integration/preprocessor/_regrid/test_regrid_schemes.py @@ -11,14 +11,14 @@ def set_data_to_const(cube, _, const=1.0): - """Dummy function to test ``GenericFuncScheme``.""" + """Compute something to test ``GenericFuncScheme``.""" cube = cube.copy(np.full(cube.shape, const)) return cube @pytest.fixture def generic_func_scheme(): - """Generic function scheme.""" + """Create a GenericFunctionScheme.""" return GenericFuncScheme(set_data_to_const, const=2) diff --git a/tests/integration/preprocessor/_supplementary_vars/test_register.py b/tests/integration/preprocessor/_supplementary_vars/test_register.py index 9512b5067e..8e9ce87685 100644 --- a/tests/integration/preprocessor/_supplementary_vars/test_register.py +++ b/tests/integration/preprocessor/_supplementary_vars/test_register.py @@ -28,7 +28,7 @@ def test_func(): def test_register_invalid_fails(): - """test that registering an invalid requirement fails.""" + """Test that registering an invalid requirement fails.""" with pytest.raises(NotImplementedError): @_supplementary_vars.register_supplementaries( diff --git a/tests/integration/recipe/test_recipe.py b/tests/integration/recipe/test_recipe.py index 5c58e9dc1a..f486db1657 100644 --- a/tests/integration/recipe/test_recipe.py +++ b/tests/integration/recipe/test_recipe.py @@ -569,7 +569,6 @@ def test_default_preprocessor_custom_order( tmp_path, patched_datafinder, session ): """Test if default settings are used when ``custom_order`` is ``True``.""" - content = dedent(""" preprocessors: default_custom_order: @@ -631,7 +630,6 @@ def test_invalid_preprocessor(tmp_path, patched_datafinder, session): def test_disable_preprocessor_function(tmp_path, patched_datafinder, session): """Test if default settings are used when ``custom_order`` is ``True``.""" - content = dedent(""" datasets: - dataset: HadGEM3-GC31-LL diff --git a/tests/integration/test_task.py b/tests/integration/test_task.py index cb8c632fbf..9570ec8e58 100644 --- a/tests/integration/test_task.py +++ b/tests/integration/test_task.py @@ -47,7 +47,7 @@ def _run(self, input_files): @pytest.fixture def example_tasks(tmp_path): - """Example tasks for testing the task runners.""" + """Create example tasks for testing the task runners.""" tasks = TaskSet() for i in range(3): task = MockBaseTask( diff --git a/tests/unit/cmor/test_cmor_check.py b/tests/unit/cmor/test_cmor_check.py index a7822ec03b..0dac7d2911 100644 --- a/tests/unit/cmor/test_cmor_check.py +++ b/tests/unit/cmor/test_cmor_check.py @@ -138,7 +138,7 @@ def test_warning_fail_on_error(self): ) def test_report_debug_message(self): - """ "Test report debug message function""" + """Test report debug message function.""" checker = CMORCheck(self.cube, self.var_info) self.assertFalse(checker.has_debug_messages()) checker.report_debug_message("New debug message") @@ -277,8 +277,7 @@ def test_rank_unstructured_grid(self): self._check_cube() def test_bad_generic_level(self): - """Test check fails in metadata if generic level coord - has wrong var_name.""" + """Test check fails if generic level coord has wrong var_name.""" depth_coord = CoordinateInfoMock("depth") depth_coord.axis = "Z" depth_coord.generic_lev_name = "olevel" @@ -344,26 +343,34 @@ def test_generic_level_invalid_alternative(self): self._check_fails_in_metadata() def test_check_bad_var_standard_name_strict_flag(self): - """Test check fails for a bad variable standard_name with - --cmor-check strict.""" + """Test check fails for a bad variable standard_name. + + With --cmor-check strict. + """ self.cube.standard_name = "wind_speed" self._check_fails_in_metadata() def test_check_bad_var_long_name_strict_flag(self): - """Test check fails for a bad variable long_name with - --cmor-check strict.""" + """Test check fails for a bad variable long_name. + + With --cmor-check strict. + """ self.cube.long_name = "Near-Surface Wind Speed" self._check_fails_in_metadata() def test_check_bad_var_units_strict_flag(self): - """Test check fails for a bad variable units with - --cmor-check strict.""" + """Test check fails for a bad variable units. + + With --cmor-check strict. + """ self.cube.units = "kg" self._check_fails_in_metadata() def test_check_bad_attributes_strict_flag(self): - """Test check fails for a bad variable attribute with - --cmor-check strict.""" + """Test check fails for a bad variable attribute. + + With --cmor-check strict. + """ self.var_info.standard_name = "surface_upward_latent_heat_flux" self.var_info.positive = "up" self.cube = self.get_cube(self.var_info) @@ -371,67 +378,78 @@ def test_check_bad_attributes_strict_flag(self): self._check_fails_in_metadata() def test_check_bad_rank_strict_flag(self): - """Test check fails for a bad variable rank with - --cmor-check strict.""" + """Test check fails for a bad variable rank with --cmor-check strict.""" lat = iris.coords.AuxCoord.from_coord(self.cube.coord("latitude")) self.cube.remove_coord("latitude") self.cube.add_aux_coord(lat, self.cube.coord_dims("longitude")) self._check_fails_in_metadata() def test_check_bad_coord_var_name_strict_flag(self): - """Test check fails for bad coord var_name with - --cmor-check strict""" + """Test check fails for bad coord var_name. + + With --cmor-check strict. + """ self.var_info.table_type = "CMIP5" self.cube.coord("longitude").var_name = "bad_name" self._check_fails_in_metadata() def test_check_missing_lon_strict_flag(self): - """Test check fails for missing longitude with --cmor-check strict""" + """Test check fails for missing longitude with --cmor-check strict.""" self.var_info.table_type = "CMIP5" self.cube.remove_coord("longitude") self._check_fails_in_metadata() def test_check_missing_lat_strict_flag(self): - """Test check fails for missing latitude with --cmor-check strict""" + """Test check fails for missing latitude with --cmor-check strict.""" self.var_info.table_type = "CMIP5" self.cube.remove_coord("latitude") self._check_fails_in_metadata() def test_check_missing_time_strict_flag(self): - """Test check fails for missing time with --cmor-check strict""" + """Test check fails for missing time with --cmor-check strict.""" self.var_info.table_type = "CMIP5" self.cube.remove_coord("time") self._check_fails_in_metadata() def test_check_missing_coord_strict_flag(self): - """Test check fails for missing coord other than lat and lon - with --cmor-check strict""" + """Test check fails for missing coord other than lat and lon. + + With --cmor-check relaxed. + """ self.var_info.coordinates.update( {"height2m": CoordinateInfoMock("height2m")} ) self._check_fails_in_metadata() def test_check_bad_var_standard_name_relaxed_flag(self): - """Test check reports warning for a bad variable standard_name with - --cmor-check relaxed.""" + """Test check reports warning for a bad variable standard_name. + + With --cmor-check relaxed. + """ self.cube.standard_name = "wind_speed" self._check_warnings_on_metadata(check_level=CheckLevels.RELAXED) def test_check_bad_var_long_name_relaxed_flag(self): - """Test check reports warning for a bad variable long_name with - --cmor-check relaxed.""" + """Test check reports warning for a bad variable long_name. + + With --cmor-check relaxed. + """ self.cube.long_name = "Near-Surface Wind Speed" self._check_warnings_on_metadata(check_level=CheckLevels.RELAXED) def test_check_bad_var_units_relaxed_flag(self): - """Test check reports warning for a bad variable units with - --cmor-check relaxed.""" + """Test check reports warning for a bad variable units. + + With --cmor-check relaxed. + """ self.cube.units = "kg" self._check_warnings_on_metadata(check_level=CheckLevels.RELAXED) def test_check_bad_attributes_relaxed_flag(self): - """Test check report warnings for a bad variable attribute with - --cmor-check relaxed.""" + """Test check report warnings for a bad variable attribute. + + With --cmor-check relaxed. + """ self.var_info.standard_name = "surface_upward_latent_heat_flux" self.var_info.positive = "up" self.cube = self.get_cube(self.var_info) @@ -439,67 +457,81 @@ def test_check_bad_attributes_relaxed_flag(self): self._check_warnings_on_metadata(check_level=CheckLevels.RELAXED) def test_check_bad_rank_relaxed_flag(self): - """Test check report warnings for a bad variable rank with - --cmor-check relaxed.""" + """Test check report warnings for a bad variable rank. + + With --cmor-check relaxed. + """ lat = iris.coords.AuxCoord.from_coord(self.cube.coord("latitude")) self.cube.remove_coord("latitude") self.cube.add_aux_coord(lat, self.cube.coord_dims("longitude")) self._check_warnings_on_metadata(check_level=CheckLevels.RELAXED) def test_check_bad_coord_standard_name_relaxed_flag(self): - """Test check reports warning for bad coord var_name with - --cmor-check relaxed""" + """Test check reports warning for bad coord var_name. + + With --cmor-check relaxed. + """ self.var_info.table_type = "CMIP5" self.cube.coord("longitude").var_name = "bad_name" self._check_warnings_on_metadata(check_level=CheckLevels.RELAXED) def test_check_missing_lon_relaxed_flag(self): - """Test check fails for missing longitude with --cmor-check relaxed""" + """Test check fails for missing longitude with --cmor-check relaxed.""" self.var_info.table_type = "CMIP5" self.cube.remove_coord("longitude") self._check_fails_in_metadata(check_level=CheckLevels.RELAXED) def test_check_missing_lat_relaxed_flag(self): - """Test check fails for missing latitude with --cmor-check relaxed""" + """Test check fails for missing latitude with --cmor-check relaxed.""" self.var_info.table_type = "CMIP5" self.cube.remove_coord("latitude") self._check_fails_in_metadata(check_level=CheckLevels.RELAXED) def test_check_missing_time_relaxed_flag(self): - """Test check fails for missing latitude with --cmor-check relaxed""" + """Test check fails for missing latitude with --cmor-check relaxed.""" self.var_info.table_type = "CMIP5" self.cube.remove_coord("time") self._check_fails_in_metadata(check_level=CheckLevels.RELAXED) def test_check_missing_coord_relaxed_flag(self): - """Test check reports warning for missing coord other than lat and lon - with --cmor-check relaxed""" + """Test check reports warning for missing coord. + + For a coordinate other than lat and lon, with --cmor-check relaxed. + """ self.var_info.coordinates.update( {"height2m": CoordinateInfoMock("height2m")} ) self._check_warnings_on_metadata(check_level=CheckLevels.RELAXED) def test_check_bad_var_standard_name_none_flag(self): - """Test check reports warning for a bad variable standard_name with - --cmor-check ignore.""" + """Test check reports warning for a bad variable standard_name. + + With --cmor-check ignore. + """ self.cube.standard_name = "wind_speed" self._check_warnings_on_metadata(check_level=CheckLevels.IGNORE) def test_check_bad_var_long_name_none_flag(self): - """Test check reports warning for a bad variable long_name with - --cmor-check ignore.""" + """Test check reports warning for a bad variable long_name. + + With --cmor-check ignore. + """ self.cube.long_name = "Near-Surface Wind Speed" self._check_warnings_on_metadata(check_level=CheckLevels.IGNORE) def test_check_bad_var_units_none_flag(self): - """Test check reports warning for a bad variable unit with - --cmor-check ignore.""" + """Test check reports warning for a bad variable unit. + + With --cmor-check ignore. + """ self.cube.units = "kg" self._check_warnings_on_metadata(check_level=CheckLevels.IGNORE) def test_check_bad_attributes_none_flag(self): - """Test check reports warning for a bad variable attribute with - --cmor-check ignore.""" + """Test check reports warning for a bad variable attribute. + + With --cmor-check ignore. + """ self.var_info.standard_name = "surface_upward_latent_heat_flux" self.var_info.positive = "up" self.cube = self.get_cube(self.var_info) @@ -507,44 +539,57 @@ def test_check_bad_attributes_none_flag(self): self._check_warnings_on_metadata(check_level=CheckLevels.IGNORE) def test_check_bad_rank_none_flag(self): - """Test check reports warning for a bad variable rank with - --cmor-check ignore.""" + """Test check reports warning for a bad variable rank. + + With --cmor-check ignore. + """ lat = iris.coords.AuxCoord.from_coord(self.cube.coord("latitude")) self.cube.remove_coord("latitude") self.cube.add_aux_coord(lat, self.cube.coord_dims("longitude")) self._check_warnings_on_metadata(check_level=CheckLevels.IGNORE) def test_check_bad_coord_standard_name_none_flag(self): - """Test check reports warning for bad coord var_name with - --cmor-check ignore.""" + """Test check reports warning for bad coord var_name. + + With --cmor-check ignore. + """ self.var_info.table_type = "CMIP5" self.cube.coord("longitude").var_name = "bad_name" self._check_warnings_on_metadata(check_level=CheckLevels.IGNORE) def test_check_missing_lon_none_flag(self): - """Test check reports warning for missing longitude with - --cmor-check ignore""" + """Test check reports warning for missing longitude. + + With --cmor-check ignore. + """ self.var_info.table_type = "CMIP5" self.cube.remove_coord("longitude") self._check_warnings_on_metadata(check_level=CheckLevels.IGNORE) def test_check_missing_lat_none_flag(self): - """Test check reports warning for missing latitude with - --cmor-check ignore""" + """Test check reports warning for missing latitude. + + With --cmor-check ignore. + """ self.var_info.table_type = "CMIP5" self.cube.remove_coord("latitude") self._check_warnings_on_metadata(check_level=CheckLevels.IGNORE) def test_check_missing_time_none_flag(self): - """Test check reports warning for missing time - with --cmor-check ignore""" + """Test check reports warning for missing time. + + With --cmor-check ignore. + """ self.var_info.table_type = "CMIP5" self.cube.remove_coord("time") self._check_warnings_on_metadata(check_level=CheckLevels.IGNORE) def test_check_missing_coord_none_flag(self): - """Test check reports warning for missing coord other than lat, lon and - time with --cmor-check ignore""" + """Test check reports warning for missing coord. + + For a coordinate other than lat, lon and time with + --cmor-check ignore. + """ self.var_info.coordinates.update( {"height2m": CoordinateInfoMock("height2m")} ) @@ -783,8 +828,7 @@ def test_bad_standard_name(self): self._check_fails_in_metadata() def test_bad_out_name_region_area_type(self): - """Debug message if region/area_type AuxCoord has bad var_name at - metadata.""" + """Test debug message if region/area_type AuxCoord has bad var_name.""" region_coord = CoordinateInfoMock("basin") region_coord.standard_name = "region" self.var_info.coordinates["region"] = region_coord @@ -795,19 +839,19 @@ def test_bad_out_name_region_area_type(self): self._check_debug_messages_on_metadata() def test_bad_out_name_onedim_latitude(self): - """Warning if onedimensional lat has bad var_name at metadata""" + """Warning if onedimensional lat has bad var_name at metadata.""" self.var_info.table_type = "CMIP6" self.cube.coord("latitude").var_name = "bad_name" self._check_fails_in_metadata() def test_bad_out_name_onedim_longitude(self): - """Warning if onedimensional lon has bad var_name at metadata""" + """Warning if onedimensional lon has bad var_name at metadata.""" self.var_info.table_type = "CMIP6" self.cube.coord("longitude").var_name = "bad_name" self._check_fails_in_metadata() def test_bad_out_name_other(self): - """Warning if general coordinate has bad var_name at metadata""" + """Warning if general coordinate has bad var_name at metadata.""" self.var_info.table_type = "CMIP6" self.cube.coord("time").var_name = "bad_name" self._check_fails_in_metadata() @@ -1034,7 +1078,7 @@ def _get_unstructed_grid_cube(self, n_bounds=2): return cube def _setup_generic_level_var(self): - """Setup var_info and cube with generic alevel coordinate.""" + """Set up var_info and cube with generic alevel coordinate.""" self.var_info.coordinates.pop("depth") self.var_info.coordinates.pop("air_pressure") diff --git a/tests/unit/cmor/test_generic_fix.py b/tests/unit/cmor/test_generic_fix.py index e1ab742619..fcc317794b 100644 --- a/tests/unit/cmor/test_generic_fix.py +++ b/tests/unit/cmor/test_generic_fix.py @@ -12,7 +12,7 @@ @pytest.fixture def generic_fix(): - """Generic fix object.""" + """Create a GenericFix object.""" vardef = get_var_info("CMIP6", "CFmon", "ta") extra_facets = {"short_name": "ta", "project": "CMIP6", "dataset": "MODEL"} return GenericFix(vardef, extra_facets=extra_facets) diff --git a/tests/unit/config/test_config_object.py b/tests/unit/config/test_config_object.py index 02da498562..09fc93ed3a 100644 --- a/tests/unit/config/test_config_object.py +++ b/tests/unit/config/test_config_object.py @@ -411,7 +411,7 @@ def test_get_global_config_deprecated(mocker, tmp_path): def _setup_config_dirs(tmp_path): - """Setup test configuration directories.""" + """Set up test configuration directories.""" config1 = tmp_path / "config1" / "1.yml" config2a = tmp_path / "config2" / "2a.yml" config2b = tmp_path / "config2" / "2b.yml" diff --git a/tests/unit/experimental/test_recipe_output.py b/tests/unit/experimental/test_recipe_output.py index 7d64935596..ca8f333e21 100644 --- a/tests/unit/experimental/test_recipe_output.py +++ b/tests/unit/experimental/test_recipe_output.py @@ -32,7 +32,6 @@ def test_diagnostic_output_repr(mocker): def test_recipe_output_add_to_filters(): """Coverage test for `RecipeOutput._add_to_filters`.""" - filters = {} valid_attr = recipe_output.RecipeOutput.FILTER_ATTRS[0] @@ -57,7 +56,6 @@ def test_recipe_output_add_to_filters(): def test_recipe_output_add_to_filters_no_attributes(): """Test `RecipeOutput._add_to_filters` with no attributes.""" - filters = {} recipe_output.RecipeOutput._add_to_filters(filters, {}) assert len(filters) == 0 @@ -65,7 +63,6 @@ def test_recipe_output_add_to_filters_no_attributes(): def test_recipe_output_add_to_filters_no_valid_attributes(): """Test `RecipeOutput._add_to_filters` with no valid attributes.""" - filters = {} invalid = "invalid_attribute" recipe_output.RecipeOutput._add_to_filters(filters, {invalid: "value"}) @@ -77,7 +74,6 @@ def test_recipe_output_add_to_filters_no_valid_attributes(): def test_recipe_output_sort_filters(): """Coverage test for `RecipeOutput._sort_filters`.""" - filters = {} valid_attr = recipe_output.RecipeOutput.FILTER_ATTRS[0] unsorted_attributes = ["1", "2", "4", "value", "3"] diff --git a/tests/unit/local/test_select_files.py b/tests/unit/local/test_select_files.py index 674912060c..570a393c8c 100644 --- a/tests/unit/local/test_select_files.py +++ b/tests/unit/local/test_select_files.py @@ -113,8 +113,7 @@ def test_select_files_sub_daily_resolution(): def test_select_files_time_period(): - """Test file selection works with time range given as duration periods of - various resolution.""" + """Test file selection works with `timerange` given as a period.""" filename_date = "pr_Amon_EC-Earth3_dcppA-hindcast_s1960-r1i1p1f1_gr_" filename_datetime = ( "psl_6hrPlev_EC-Earth3_dcppA-hindcast_s1960-r1i1p1f1_gr_" @@ -153,8 +152,7 @@ def test_select_files_time_period(): def test_select_files_varying_format(): - """Test file selection works with time range of various time resolutions - and formats.""" + """Test file selection works with various `timerange`s.""" filename = "psl_6hrPlev_EC-Earth3_dcppA-hindcast_s1960-r1i1p1f1_gr_" files = [ diff --git a/tests/unit/local/test_time.py b/tests/unit/local/test_time.py index 31afbedee3..b6a29f450c 100644 --- a/tests/unit/local/test_time.py +++ b/tests/unit/local/test_time.py @@ -212,8 +212,10 @@ def test_fails_if_no_date_present(): def test_get_timerange_from_years(): - """Test a `timerange` tag with value `start_year/end_year` can be built - from tags `start_year` and `end_year`.""" + """Test a `timerange` with value `start_year/end_year` can be built. + + From `start_year` and `end_year`. + """ variable = {"start_year": 2000, "end_year": 2002} _replace_years_with_timerange(variable) @@ -224,8 +226,10 @@ def test_get_timerange_from_years(): def test_get_timerange_from_start_year(): - """Test a `timerange` tag with value `start_year/start_year` can be built - from tag `start_year` when an `end_year` is not given.""" + """Test a `timerange` with value `start_year/start_year` can be built. + + From `start_year` when an `end_year` is not given. + """ variable = {"start_year": 2000} _replace_years_with_timerange(variable) @@ -235,8 +239,10 @@ def test_get_timerange_from_start_year(): def test_get_timerange_from_end_year(): - """Test a `timerange` tag with value `end_year/end_year` can be built from - tag `end_year` when a `start_year` is not given.""" + """Test a `timerange` with value `end_year/end_year` can be built. + + From `end_year` when a `start_year` is not given. + """ variable = {"end_year": 2002} _replace_years_with_timerange(variable) diff --git a/tests/unit/preprocessor/_area/test_area.py b/tests/unit/preprocessor/_area/test_area.py index 99eaf3f150..ec741b629a 100644 --- a/tests/unit/preprocessor/_area/test_area.py +++ b/tests/unit/preprocessor/_area/test_area.py @@ -233,8 +233,10 @@ def test_extract_region(self): self.assert_array_equal(result.data, expected) def test_extract_region_mean(self): - """Test for extracting a region and performing the area mean of a 2D - field.""" + """Test for extracting a region and performing the area mean. + + Use a 2D field. + """ cube = guess_bounds(self.grid, ["longitude", "latitude"]) grid_areas = iris.analysis.cartography.area_weights(cube) measure = iris.coords.CellMeasure( diff --git a/tests/unit/preprocessor/_compare_with_refs/test_compare_with_refs.py b/tests/unit/preprocessor/_compare_with_refs/test_compare_with_refs.py index 631eac916d..003cba71dc 100644 --- a/tests/unit/preprocessor/_compare_with_refs/test_compare_with_refs.py +++ b/tests/unit/preprocessor/_compare_with_refs/test_compare_with_refs.py @@ -78,7 +78,7 @@ def regular_cubes(): @pytest.fixture def ref_cubes(): - """Reference cubes.""" + """Create reference cubes.""" cube_data = np.full((2, 2, 2), 2.0) cube_data[1, 1, 1] = 4.0 cube = get_3d_cube( diff --git a/tests/unit/preprocessor/_mask/test_mask.py b/tests/unit/preprocessor/_mask/test_mask.py index 9eca669d38..59b383c59a 100644 --- a/tests/unit/preprocessor/_mask/test_mask.py +++ b/tests/unit/preprocessor/_mask/test_mask.py @@ -115,7 +115,7 @@ def test_get_fx_mask(self): self.assert_array_equal(expected, computed) def test_mask_glaciated(self): - """Test to mask glaciated (NE mask)""" + """Test to mask glaciated (NE mask).""" result = mask_glaciated(self.arr, mask_out="glaciated") expected = np.ma.masked_array( self.data2, mask=np.array([[True, True], [False, False]]) diff --git a/tests/unit/preprocessor/_regrid/__init__.py b/tests/unit/preprocessor/_regrid/__init__.py index a6869d33cf..a59bbc5662 100644 --- a/tests/unit/preprocessor/_regrid/__init__.py +++ b/tests/unit/preprocessor/_regrid/__init__.py @@ -1,7 +1,4 @@ -""" -Unit tests for the :mod:`esmvalcore.preprocessor.regrid` module. - -""" +"""Unit tests for the :mod:`esmvalcore.preprocessor.regrid` module.""" from typing import Literal @@ -12,10 +9,7 @@ def _make_vcoord(data, dtype=None): - """ - Create a synthetic test vertical coordinate. - - """ + """Create a synthetic test vertical coordinate.""" if dtype is None: dtype = np.dtype("int8") @@ -49,10 +43,7 @@ def _make_cube( dtype=None, grid: Literal["regular", "rotated", "mesh"] = "regular", ): - """ - Create a 3d synthetic test cube. - - """ + """Create a 3d synthetic test cube.""" if dtype is None: dtype = np.dtype("int8") diff --git a/tests/unit/preprocessor/_regrid/test__create_cube.py b/tests/unit/preprocessor/_regrid/test__create_cube.py index 0308df61ae..4ec1e97b60 100644 --- a/tests/unit/preprocessor/_regrid/test__create_cube.py +++ b/tests/unit/preprocessor/_regrid/test__create_cube.py @@ -1,8 +1,4 @@ -""" -Unit tests for the :func:`esmvalcore.preprocessor.regrid._create_cube` -function. - -""" +"""Unit tests for :func:`esmvalcore.preprocessor.regrid._create_cube`.""" import unittest diff --git a/tests/unit/preprocessor/_regrid/test__stock_cube.py b/tests/unit/preprocessor/_regrid/test__stock_cube.py index 220c7195e8..df2c50c330 100644 --- a/tests/unit/preprocessor/_regrid/test__stock_cube.py +++ b/tests/unit/preprocessor/_regrid/test__stock_cube.py @@ -1,8 +1,4 @@ -""" -Unit tests for the :func:`esmvalcore.preprocessor.regrid._stock_cube` -function. - -""" +"""Unit tests for :func:`esmvalcore.preprocessor.regrid._stock_cube`.""" import unittest from unittest import mock diff --git a/tests/unit/preprocessor/_regrid/test_extract_point.py b/tests/unit/preprocessor/_regrid/test_extract_point.py index f131463f3e..b266835b8f 100644 --- a/tests/unit/preprocessor/_regrid/test_extract_point.py +++ b/tests/unit/preprocessor/_regrid/test_extract_point.py @@ -1,8 +1,4 @@ -""" -Unit tests for the -:func:`esmvalcore.preprocessor.regrid.extract_point` function. - -""" +"""Unit tests for :func:`esmvalcore.preprocessor.extract_point`.""" import unittest from unittest import mock diff --git a/tests/unit/preprocessor/_regrid/test_extract_regional_grid.py b/tests/unit/preprocessor/_regrid/test_extract_regional_grid.py index 15055a7658..6ff0df6fec 100644 --- a/tests/unit/preprocessor/_regrid/test_extract_regional_grid.py +++ b/tests/unit/preprocessor/_regrid/test_extract_regional_grid.py @@ -1,4 +1,4 @@ -"""Unit test for :func:`esmvalcore.preprocessor._regrid`""" +"""Unit test for :func:`esmvalcore.preprocessor._regrid`.""" from decimal import Decimal diff --git a/tests/unit/preprocessor/_regrid/test_regrid.py b/tests/unit/preprocessor/_regrid/test_regrid.py index 69589a7a8c..3521a35053 100644 --- a/tests/unit/preprocessor/_regrid/test_regrid.py +++ b/tests/unit/preprocessor/_regrid/test_regrid.py @@ -1,5 +1,4 @@ -"""Unit tests for the :func:`esmvalcore.preprocessor.regrid.regrid` -function.""" +"""Unit tests for :func:`esmvalcore.preprocessor.regrid`.""" import dask import dask.array as da @@ -25,7 +24,7 @@ def clear_regridder_cache(monkeypatch): def _make_coord(start: float, stop: float, step: int, *, name: str): - """Helper function for creating a coord.""" + """Create a latitude or longitude coordinate with bounds.""" coord = iris.coords.DimCoord( np.linspace(start, stop, step), standard_name=name, @@ -36,7 +35,7 @@ def _make_coord(start: float, stop: float, step: int, *, name: str): def _make_cube(*, lat: tuple, lon: tuple): - """Helper function for creating a cube.""" + """Create a cube with a latitude and longitude dimension.""" lat_coord = _make_coord(*lat, name="latitude") lon_coord = _make_coord(*lon, name="longitude") @@ -83,7 +82,7 @@ def cube_30x30(): @pytest.mark.parametrize("cache_weights", [True, False]) @pytest.mark.parametrize("scheme", SCHEMES) def test_builtin_regridding(scheme, cache_weights, cube_10x10, cube_30x30): - """Test `regrid.`""" + """Test `regrid.`.""" _cached_regridders = esmvalcore.preprocessor._regrid._CACHED_REGRIDDERS assert _cached_regridders == {} @@ -104,7 +103,7 @@ def test_builtin_regridding(scheme, cache_weights, cube_10x10, cube_30x30): @pytest.mark.parametrize("scheme", SCHEMES) def test_invalid_target_grid(scheme, cube_10x10, mocker): - """Test `regrid.`""" + """Test `regrid.`.""" target_grid = mocker.sentinel.target_grid msg = "Expecting a cube" with pytest.raises(ValueError, match=msg): @@ -112,7 +111,7 @@ def test_invalid_target_grid(scheme, cube_10x10, mocker): def test_invalid_scheme(cube_10x10, cube_30x30): - """Test `regrid.`""" + """Test `regrid.`.""" msg = ( "Regridding scheme 'wibble' not available for regular data, " "expected one of: area_weighted, linear, nearest" @@ -122,14 +121,14 @@ def test_invalid_scheme(cube_10x10, cube_30x30): def test_regrid_generic_missing_reference(cube_10x10, cube_30x30): - """Test `regrid.`""" + """Test `regrid.`.""" msg = "No reference specified for generic regridding." with pytest.raises(ValueError, match=msg): regrid(cube_10x10, cube_30x30, {}) def test_regrid_generic_invalid_reference(cube_10x10, cube_30x30): - """Test `regrid.`""" + """Test `regrid.`.""" msg = "Could not import specified generic regridding module." with pytest.raises(ValueError, match=msg): regrid(cube_10x10, cube_30x30, {"reference": "this.does:not.exist"}) @@ -137,7 +136,7 @@ def test_regrid_generic_invalid_reference(cube_10x10, cube_30x30): @pytest.mark.parametrize("cache_weights", [True, False]) def test_regrid_generic_regridding(cache_weights, cube_10x10, cube_30x30): - """Test `regrid.`""" + """Test `regrid.`.""" _cached_regridders = esmvalcore.preprocessor._regrid._CACHED_REGRIDDERS assert _cached_regridders == {} @@ -401,7 +400,7 @@ def test_no_rechunk_non_lazy(): @pytest.mark.parametrize("scheme", SCHEMES) def test_regridding_weights_use_cache(scheme, cube_10x10, cube_30x30, mocker): - """Test `regrid.`""" + """Test `regrid.`.""" _cached_regridders = esmvalcore.preprocessor._regrid._CACHED_REGRIDDERS assert _cached_regridders == {} @@ -429,7 +428,7 @@ def test_regridding_weights_use_cache(scheme, cube_10x10, cube_30x30, mocker): def test_clear_regridding_weights_cache(): - """Test `regrid.cache_clear().`""" + """Test `regrid.cache_clear().`.""" _cached_regridders = esmvalcore.preprocessor._regrid._CACHED_REGRIDDERS _cached_regridders["test"] = "test" diff --git a/tests/unit/preprocessor/_time/test_time.py b/tests/unit/preprocessor/_time/test_time.py index d3518e348d..54db6ed2b8 100644 --- a/tests/unit/preprocessor/_time/test_time.py +++ b/tests/unit/preprocessor/_time/test_time.py @@ -351,8 +351,10 @@ def test_clip_timerange_daily(self): assert sliced_backward.coord("time").cell(0).point.day == 1 def test_clip_timerange_duration_seconds(self): - """Test timerange with duration periods with resolution up to - seconds.""" + """Test clip_timerange. + + Test with duration periods with resolution up to seconds. + """ data = np.arange(8) times = np.arange(0, 48, 6) calendars = [ @@ -1305,7 +1307,7 @@ def test_sum(self): @pytest.fixture def cube_1d_time(): - """Simple 1D cube with time coordinate of length one.""" + """Create a 1D cube with a time coordinate of length one.""" units = Unit("days since 2000-01-01", calendar="standard") time_coord = iris.coords.DimCoord( units.date2num(datetime(2024, 1, 26, 14, 57, 28)), diff --git a/tests/unit/preprocessor/_volume/test_volume.py b/tests/unit/preprocessor/_volume/test_volume.py index 682d42fd45..1dec034b4e 100644 --- a/tests/unit/preprocessor/_volume/test_volume.py +++ b/tests/unit/preprocessor/_volume/test_volume.py @@ -441,8 +441,7 @@ def test_extract_volume_error(self): ) def test_extract_volume_mean(self): - """Test to extract the top two layers and compute the weighted average - of a cube.""" + """Test extracting the top layers and computing the weighted mean.""" grid_volume = calculate_volume(self.grid_4d) assert isinstance(grid_volume, np.ndarray) measure = iris.coords.CellMeasure( @@ -479,10 +478,10 @@ def test_volume_statistics(self): self.assertFalse(result.cell_measures("ocean_volume")) def test_volume_nolevbounds(self): - """Test to take the volume weighted average of a cube with no bounds - in the z axis. - """ + """Test to take the volume weighted average of a cube. + Test a cube with no bounds in the z axis. + """ self.assertFalse(self.grid_4d_znobounds.coord(axis="z").has_bounds()) result = volume_statistics(self.grid_4d_znobounds, "mean") @@ -493,7 +492,7 @@ def test_volume_nolevbounds(self): self.assertFalse(result.cell_measures("ocean_volume")) def test_calculate_volume_lazy(self): - """Test that calculate_volume returns a lazy volume + """Test that calculate_volume returns a lazy volume. The volume chunks should match those of the input cube for computational efficiency. @@ -553,16 +552,22 @@ def test_volume_statistics_long(self): self.assertEqual(result.units, "kg m-3") def test_volume_statistics_masked_level(self): - """Test to take the volume weighted average of a (2,3,2,2) cube where - the last depth level is fully masked.""" + """Test to take the volume weighted average. + + This is a test for a (2,3,2,2) cube where the last depth level is fully + masked. + """ self.grid_4d.data[:, -1, :, :] = np.ma.masked_all((2, 2, 2)) result = volume_statistics(self.grid_4d, "mean") expected = np.ma.array([1.0, 1.0], mask=False) self.assert_array_equal(result.data, expected) def test_volume_statistics_masked_timestep(self): - """Test to take the volume weighted average of a (2,3,2,2) cube where - the first timestep is fully masked.""" + """Test taking the volume weighted average. + + This is a test for a (2,3,2,2) cube where the first timestep is fully + masked. + """ self.grid_4d.data[0, :, :, :] = np.ma.masked_all((3, 2, 2)) result = volume_statistics(self.grid_4d, "mean") expected = np.ma.array([1.0, 1], mask=[True, False]) @@ -653,8 +658,7 @@ def test_volume_statistics_2d_lat_cellarea(self): self.assertEqual(result.units, "kg m-3") def test_volume_statistics_invalid_bounds(self): - """Test z-axis bounds is not 2 in last dimension""" - + """Test z-axis bounds is not 2 in last dimension.""" with self.assertRaises(ValueError) as err: volume_statistics(self.grid_invalid_z_bounds, "mean") assert ( @@ -663,8 +667,7 @@ def test_volume_statistics_invalid_bounds(self): ) in str(err.exception) def test_volume_statistics_invalid_units(self): - """Test z-axis units cannot be converted to m""" - + """Test z-axis units cannot be converted to m.""" with self.assertRaises(ValueError) as err: volume_statistics(self.grid_4d_sigma_space, "mean") assert ( diff --git a/tests/unit/preprocessor/test_shared.py b/tests/unit/preprocessor/test_shared.py index b0a990c45d..90dd04135b 100644 --- a/tests/unit/preprocessor/test_shared.py +++ b/tests/unit/preprocessor/test_shared.py @@ -181,7 +181,7 @@ def test_aggregator_accept_weights(aggregator, result): @preserve_float_dtype def _dummy_func(obj, arg, kwarg=2.0): - """Dummy function to test `preserve_float_dtype`.""" + """Compute something to test `preserve_float_dtype`.""" obj = obj * arg * kwarg if isinstance(obj, Cube): obj.data = obj.core_data().astype(np.float64) diff --git a/tests/unit/recipe/test_recipe.py b/tests/unit/recipe/test_recipe.py index 4dd142bc43..9934f02d3b 100644 --- a/tests/unit/recipe/test_recipe.py +++ b/tests/unit/recipe/test_recipe.py @@ -20,7 +20,7 @@ class MockRecipe(_recipe.Recipe): """Mocked Recipe class with simple constructor.""" def __init__(self, cfg, diagnostics): - """Simple constructor used for testing.""" + """Create a mock recipe for testing.""" self.session = cfg self.diagnostics = diagnostics diff --git a/tests/unit/test_naming.py b/tests/unit/test_naming.py index da453eee4f..faa97a431a 100644 --- a/tests/unit/test_naming.py +++ b/tests/unit/test_naming.py @@ -1,20 +1,20 @@ -"""Checks to ensure that files follow the naming convention""" +"""Checks to ensure that files follow the naming convention.""" import os import unittest class TestNaming(unittest.TestCase): - """Test naming of files and folders""" + """Test naming of files and folders.""" def setUp(self): - """Prepare tests""" + """Prepare tests.""" folder = os.path.join(__file__, "..", "..", "..") self.esmvaltool_folder = os.path.abspath(folder) def test_windows_reserved_names(self): """ - Check that no file or folder uses a Windows reserved name + Check that no file or folder uses a Windows reserved name. Files can not differ from a reserved name by the extension only """ @@ -61,7 +61,7 @@ def test_windows_reserved_names(self): def test_avoid_casing_collisions(self): """ - Check that there are no names differing only in the capitalization + Check that there are no names differing only in the capitalization. This includes folders differing from files """ @@ -76,7 +76,7 @@ def test_avoid_casing_collisions(self): def test_no_namelist(self): """ - Check that there are no namelist references in file and folder names + Check that there are no namelist references in file and folder names. This will help us to avoid bad merges with stale branches """