From 45b02069135f3e8b67c6c90c806bf21b7098a946 Mon Sep 17 00:00:00 2001 From: Magdalena Luz Date: Fri, 6 Oct 2023 21:06:39 +0200 Subject: [PATCH] pass hooks pytest_config.py via pytest config file --- .../advection/advection_tests/conftest.py | 22 +++---------------- model/atmosphere/advection/pyproject.toml | 1 + .../diffusion/diffusion_tests/conftest.py | 6 ----- model/atmosphere/diffusion/pyproject.toml | 1 + model/atmosphere/dycore/pyproject.toml | 1 + model/atmosphere/dycore/tests/conftest.py | 6 ----- model/common/pyproject.toml | 1 + model/common/tests/conftest.py | 6 ----- model/driver/pyproject.toml | 1 + model/driver/tests/conftest.py | 5 ----- model/tox.ini | 2 ++ pytest.ini | 1 + 12 files changed, 11 insertions(+), 42 deletions(-) diff --git a/model/atmosphere/advection/advection_tests/conftest.py b/model/atmosphere/advection/advection_tests/conftest.py index 7ee1151470..ae7f566989 100644 --- a/model/atmosphere/advection/advection_tests/conftest.py +++ b/model/atmosphere/advection/advection_tests/conftest.py @@ -10,24 +10,8 @@ # distribution for a copy of the license or check . # # SPDX-License-Identifier: GPL-3.0-or-later -import pytest -from gt4py.next.program_processors.runners.roundtrip import executor -from icon4py.model.common.test_utils.simple_mesh import SimpleMesh - - -BACKENDS = {"embedded": executor} -MESHES = {"simple_mesh": SimpleMesh()} - - -@pytest.fixture( - ids=MESHES.keys(), - params=MESHES.values(), +from icon4py.model.common.test_utils.fixtures import ( # noqa : F401 # fixtures from test_utils + backend, + mesh, ) -def mesh(request): - return request.param - - -@pytest.fixture(ids=BACKENDS.keys(), params=BACKENDS.values()) -def backend(request): - return request.param diff --git a/model/atmosphere/advection/pyproject.toml b/model/atmosphere/advection/pyproject.toml index f26f25f3b4..9a659352eb 100644 --- a/model/atmosphere/advection/pyproject.toml +++ b/model/atmosphere/advection/pyproject.toml @@ -110,6 +110,7 @@ warn_unused_ignores = true [tool.pytest] [tool.pytest.ini_options] +addopts = ['-p icon4py.model.common.test_utils.pytest_config'] markers = 'slow_tests: marks tests as slow' testpaths = ['tests', 'advection_tests'] diff --git a/model/atmosphere/diffusion/diffusion_tests/conftest.py b/model/atmosphere/diffusion/diffusion_tests/conftest.py index b00ec804c5..d429204442 100644 --- a/model/atmosphere/diffusion/diffusion_tests/conftest.py +++ b/model/atmosphere/diffusion/diffusion_tests/conftest.py @@ -33,12 +33,6 @@ step_date_exit, step_date_init, ) -from icon4py.model.common.test_utils.pytest_config import ( # noqa: F401 - pytest_addoption, - pytest_configure, - pytest_generate_tests, - pytest_runtest_setup, -) @pytest.fixture diff --git a/model/atmosphere/diffusion/pyproject.toml b/model/atmosphere/diffusion/pyproject.toml index 8389cb9b4b..8714103bef 100644 --- a/model/atmosphere/diffusion/pyproject.toml +++ b/model/atmosphere/diffusion/pyproject.toml @@ -109,6 +109,7 @@ warn_unused_ignores = true [tool.pytest] [tool.pytest.ini_options] +addopts = ['-p icon4py.model.common.test_utils.pytest_config'] markers = [ "datatest: test depending on serialized data generated by a full model run" ] diff --git a/model/atmosphere/dycore/pyproject.toml b/model/atmosphere/dycore/pyproject.toml index a29c25ea69..8f626ee19d 100644 --- a/model/atmosphere/dycore/pyproject.toml +++ b/model/atmosphere/dycore/pyproject.toml @@ -110,6 +110,7 @@ warn_unused_ignores = true [tool.pytest] [tool.pytest.ini_options] +addopts = ['-p icon4py.model.common.test_utils.pytest_config'] testpaths = 'tests' [tool.setuptools.dynamic] diff --git a/model/atmosphere/dycore/tests/conftest.py b/model/atmosphere/dycore/tests/conftest.py index 2a512fb365..8e6147e6d2 100644 --- a/model/atmosphere/dycore/tests/conftest.py +++ b/model/atmosphere/dycore/tests/conftest.py @@ -25,9 +25,3 @@ step_date_exit, step_date_init, ) -from icon4py.model.common.test_utils.pytest_config import ( # noqa: F401 - pytest_addoption, - pytest_configure, - pytest_generate_tests, - pytest_runtest_setup, -) diff --git a/model/common/pyproject.toml b/model/common/pyproject.toml index 794413c086..6aa277c285 100644 --- a/model/common/pyproject.toml +++ b/model/common/pyproject.toml @@ -109,6 +109,7 @@ warn_unused_ignores = true [tool.pytest] [tool.pytest.ini_options] +addopts = ['-p icon4py.model.common.test_utils.pytest_config'] markers = [ "datatest: test depending on serialized data generated by a full model run", "with_netcdf: test depending on a compatible version of netCDF4" diff --git a/model/common/tests/conftest.py b/model/common/tests/conftest.py index b69324c5a2..ce8276620c 100644 --- a/model/common/tests/conftest.py +++ b/model/common/tests/conftest.py @@ -28,12 +28,6 @@ processor_props, ranked_data_path, ) -from icon4py.model.common.test_utils.pytest_config import ( # noqa: F401 - pytest_addoption, - pytest_configure, - pytest_generate_tests, - pytest_runtest_setup, -) grids_path = base_path.joinpath("grids") diff --git a/model/driver/pyproject.toml b/model/driver/pyproject.toml index 693f257cc6..54b2410297 100644 --- a/model/driver/pyproject.toml +++ b/model/driver/pyproject.toml @@ -115,6 +115,7 @@ warn_unused_ignores = true [tool.pytest] [tool.pytest.ini_options] +addopts = ['-p icon4py.model.common.test_utils.pytest_config'] testpaths = 'tests' [tool.setuptools.dynamic] diff --git a/model/driver/tests/conftest.py b/model/driver/tests/conftest.py index d9ad439dc9..d7562f33d9 100644 --- a/model/driver/tests/conftest.py +++ b/model/driver/tests/conftest.py @@ -17,8 +17,3 @@ processor_props, ranked_data_path, ) -from icon4py.model.common.test_utils.pytest_config import ( # noqa: F401 - pytest_addoption, - pytest_configure, - pytest_runtest_setup, -) diff --git a/model/tox.ini b/model/tox.ini index 42edca3083..e59fc2737b 100644 --- a/model/tox.ini +++ b/model/tox.ini @@ -33,3 +33,5 @@ skip_install = true commands = commands_post = +[pytest] +addopts = -p icon4py.model.common.test_utils.pytest_config diff --git a/pytest.ini b/pytest.ini index c796932b5c..60bb4d8630 100644 --- a/pytest.ini +++ b/pytest.ini @@ -4,3 +4,4 @@ markers = slow_tests: mark test as slow. datatest: test depending on serialized data generated by a full model run with_netcdf: test depending on a compatible version of netCDF4 +addopts = -p icon4py.model.common.test_utils.pytest_config