Skip to content

Commit

Permalink
Parametrize for loops
Browse files Browse the repository at this point in the history
  • Loading branch information
maddenp-noaa committed Jun 24, 2024
1 parent e015477 commit e997254
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 45 deletions.
13 changes: 8 additions & 5 deletions src/uwtools/tests/drivers/test_esg_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import f90nml # type: ignore
from iotaa import refs
from pytest import fixture
from pytest import fixture, mark

from uwtools.drivers.driver import Driver
from uwtools.drivers.esg_grid import ESGGrid
Expand Down Expand Up @@ -62,8 +62,9 @@ def driverobj(config):
# Tests


def test_ESGGrid():
for method in [
@mark.parametrize(
"method",
[
"_driver_config",
"_resources",
"_run_via_batch_submission",
Expand All @@ -78,8 +79,10 @@ def test_ESGGrid():
"_write_runscript",
"run",
"runscript",
]:
assert getattr(ESGGrid, method) is getattr(Driver, method)
],
)
def test_ESGGrid(method):
assert getattr(ESGGrid, method) is getattr(Driver, method)


def test_ESGGrid_namelist_file(caplog, driverobj):
Expand Down
13 changes: 8 additions & 5 deletions src/uwtools/tests/drivers/test_filter_topo.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import f90nml # type: ignore
from iotaa import refs
from pytest import fixture
from pytest import fixture, mark

from uwtools.config.support import from_od
from uwtools.drivers.driver import Driver
Expand Down Expand Up @@ -57,8 +57,9 @@ def driverobj(config):
# Tests


def test_FilterTopo():
for method in [
@mark.parametrize(
"method",
[
"_driver_config",
"_resources",
"_run_via_batch_submission",
Expand All @@ -73,8 +74,10 @@ def test_FilterTopo():
"_write_runscript",
"run",
"runscript",
]:
assert getattr(FilterTopo, method) is getattr(Driver, method)
],
)
def test_FilterTopo(method):
assert getattr(FilterTopo, method) is getattr(Driver, method)


def test_FilterTopo_input_grid_file(driverobj):
Expand Down
13 changes: 8 additions & 5 deletions src/uwtools/tests/drivers/test_ioda.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from unittest.mock import DEFAULT as D
from unittest.mock import patch

from pytest import fixture
from pytest import fixture, mark

from uwtools.drivers.ioda import IODA
from uwtools.drivers.jedi_base import JEDIBase
Expand Down Expand Up @@ -67,8 +67,9 @@ def driverobj(config, cycle):
# Tests


def test_IODA():
for method in [
@mark.parametrize(
"method",
[
"_driver_config",
"_resources",
"_run_via_batch_submission",
Expand All @@ -81,8 +82,10 @@ def test_IODA():
"_write_runscript",
"run",
"runscript",
]:
assert getattr(IODA, method) is getattr(JEDIBase, method)
],
)
def test_IODA(method):
assert getattr(IODA, method) is getattr(JEDIBase, method)


def test_IODA_provisioned_run_directory(driverobj):
Expand Down
13 changes: 8 additions & 5 deletions src/uwtools/tests/drivers/test_make_hgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from unittest.mock import DEFAULT as D
from unittest.mock import patch

from pytest import fixture
from pytest import fixture, mark

from uwtools.drivers.driver import Driver
from uwtools.drivers.make_hgrid import MakeHgrid
Expand Down Expand Up @@ -48,8 +48,9 @@ def driverobj(config):
# Tests


def test_MakeHgrid():
for method in [
@mark.parametrize(
"method",
[
"_driver_config",
"_resources",
"_run_via_batch_submission",
Expand All @@ -63,8 +64,10 @@ def test_MakeHgrid():
"_write_runscript",
"run",
"runscript",
]:
assert getattr(MakeHgrid, method) is getattr(Driver, method)
],
)
def test_MakeHgrid(method):
assert getattr(MakeHgrid, method) is getattr(Driver, method)


def test_MakeHgrid_provisioned_run_directory(driverobj):
Expand Down
13 changes: 8 additions & 5 deletions src/uwtools/tests/drivers/test_schism.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from unittest.mock import patch

import yaml
from pytest import fixture
from pytest import fixture, mark

from uwtools.drivers.driver import Assets
from uwtools.drivers.schism import SCHISM
Expand Down Expand Up @@ -43,13 +43,16 @@ def driverobj(config, cycle):
# Tests


def test_SCHISM():
for method in [
@mark.parametrize(
"method",
[
"_driver_config",
"_taskname",
"_validate",
]:
assert getattr(SCHISM, method) is getattr(Assets, method)
],
)
def test_SCHISM(method):
assert getattr(SCHISM, method) is getattr(Assets, method)


def test_SCHISM_namelist_file(driverobj):
Expand Down
13 changes: 8 additions & 5 deletions src/uwtools/tests/drivers/test_sfc_climo_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import f90nml # type: ignore
from iotaa import asset, external, refs
from pytest import fixture
from pytest import fixture, mark

from uwtools.drivers import sfc_climo_gen
from uwtools.drivers.driver import Driver
Expand Down Expand Up @@ -84,8 +84,9 @@ def driverobj(config):
# Tests


def test_SfcClimoGen():
for method in [
@mark.parametrize(
"method",
[
"_driver_config",
"_resources",
"_run_via_batch_submission",
Expand All @@ -100,8 +101,10 @@ def test_SfcClimoGen():
"_write_runscript",
"run",
"runscript",
]:
assert getattr(SfcClimoGen, method) is getattr(Driver, method)
],
)
def test_SfcClimoGen(method):
assert getattr(SfcClimoGen, method) is getattr(Driver, method)


def test_SfcClimoGen_namelist_file(caplog, driverobj):
Expand Down
13 changes: 8 additions & 5 deletions src/uwtools/tests/drivers/test_shave.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from unittest.mock import DEFAULT as D
from unittest.mock import patch

from pytest import fixture
from pytest import fixture, mark

from uwtools.drivers.driver import Driver
from uwtools.drivers.shave import Shave
Expand Down Expand Up @@ -49,8 +49,9 @@ def driverobj(config):
# Tests


def test_Shave():
for method in [
@mark.parametrize(
"method",
[
"_driver_config",
"_resources",
"_run_via_batch_submission",
Expand All @@ -64,8 +65,10 @@ def test_Shave():
"_write_runscript",
"run",
"runscript",
]:
assert getattr(Shave, method) is getattr(Driver, method)
],
)
def test_Shave(method):
assert getattr(Shave, method) is getattr(Driver, method)


def test_Shave_provisioned_run_directory(driverobj):
Expand Down
13 changes: 8 additions & 5 deletions src/uwtools/tests/drivers/test_upp.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import f90nml # type: ignore
from iotaa import refs
from pytest import fixture
from pytest import fixture, mark

from uwtools.drivers.driver import Driver
from uwtools.drivers.upp import UPP
Expand Down Expand Up @@ -77,8 +77,9 @@ def leadtime():
# Tests


def test_UPP():
for method in [
@mark.parametrize(
"method",
[
"_driver_config",
"_resources",
"_run_via_batch_submission",
Expand All @@ -91,8 +92,10 @@ def test_UPP():
"_write_runscript",
"run",
"runscript",
]:
assert getattr(UPP, method) is getattr(Driver, method)
],
)
def test_UPP(method):
assert getattr(UPP, method) is getattr(Driver, method)


def test_UPP_files_copied(driverobj):
Expand Down
13 changes: 8 additions & 5 deletions src/uwtools/tests/drivers/test_ww3.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from unittest.mock import patch

import yaml
from pytest import fixture
from pytest import fixture, mark

from uwtools.drivers.driver import Assets
from uwtools.drivers.ww3 import WaveWatchIII
Expand Down Expand Up @@ -43,13 +43,16 @@ def driverobj(config, cycle):
# Tests


def test_WaveWatchIII():
for method in [
@mark.parametrize(
"method",
[
"_driver_config",
"_taskname",
"_validate",
]:
assert getattr(WaveWatchIII, method) is getattr(Assets, method)
],
)
def test_WaveWatchIII(method):
assert getattr(WaveWatchIII, method) is getattr(Assets, method)


def test_WaveWatchIII_namelist_file(driverobj):
Expand Down

0 comments on commit e997254

Please sign in to comment.