From 79721d7395272eb2ba145c5102cbd44d0fc42c5e Mon Sep 17 00:00:00 2001 From: Lukas Pilz Date: Fri, 11 Oct 2024 15:31:25 +0200 Subject: [PATCH] Patches (#191) * Bump black versions to the supported ones * Register network marker for pytest * Replaced pkg_resources with importlib because of depreciation in 3.12 * Fixed test warning by dropping duplicate coordinate * Disabled test because dataset has no horizontal extent * Suppress uneccessary xgcm DeprecationWarning for Axis which we don't use --- pyproject.toml | 6 +++++- tests/test_metpy.py | 2 +- tests/test_postprocess.py | 7 +++++-- xwrf/__init__.py | 6 +++--- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ccca61b1..39fb679e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,12 @@ [tool.black] line-length = 100 -target-version = ['py39', 'py310', 'py311', 'py312'] +target-version = ["py310", "py311", "py312"] skip-string-normalization = true +[tool.pytest.ini_options] +markers = [ + "network: mark test as requiring network access", +] [build-system] requires = ["setuptools>=30.3.0", "wheel", "setuptools_scm"] diff --git a/tests/test_metpy.py b/tests/test_metpy.py index ea341952..e2a049dc 100644 --- a/tests/test_metpy.py +++ b/tests/test_metpy.py @@ -48,7 +48,7 @@ def test_metpy_coordinate_identification(sample_dataset): indirect=['sample_dataset'], ) def test_metpy_axis_identification(sample_dataset, axis_mapping, test_varname): - da = sample_dataset.xwrf.postprocess()[test_varname] + da = sample_dataset.xwrf.postprocess()[test_varname].drop_vars('CLAT') for axis_type, axis_number in axis_mapping.items(): assert da.metpy.find_axis_number(axis_type) == axis_number assert da.metpy.find_axis_name(axis_type) == da.dims[axis_number] diff --git a/tests/test_postprocess.py b/tests/test_postprocess.py index fd3ea768..a79a955f 100644 --- a/tests/test_postprocess.py +++ b/tests/test_postprocess.py @@ -61,7 +61,9 @@ def test_include_projection_coordinates(sample_dataset): @pytest.mark.parametrize( - 'sample_dataset', set(xwrf.tutorial.sample_datasets.keys()) - {'tiny', 'ideal'}, indirect=True + 'sample_dataset', + set(xwrf.tutorial.sample_datasets.keys()) - {'tiny', 'ideal', 'dummy_attrs_only'}, + indirect=True, ) def test_grid_mapping_is_in_all_vars(sample_dataset): dataset = xwrf.postprocess._include_projection_coordinates(sample_dataset) @@ -77,7 +79,8 @@ def test_include_projection_coordinates_with_xgcm(sample_dataset): from xgcm import Grid dataset = xwrf.postprocess._include_projection_coordinates(sample_dataset) - grid = Grid(dataset) + with pytest.warns(DeprecationWarning): + grid = Grid(dataset, periodic=False) assert grid.axes['Y'].coords['center'] == 'south_north' assert grid.axes['Y'].coords['outer'] == 'south_north_stag' diff --git a/xwrf/__init__.py b/xwrf/__init__.py index 93d9acab..f37302ca 100644 --- a/xwrf/__init__.py +++ b/xwrf/__init__.py @@ -2,7 +2,7 @@ # flake8: noqa """ Top-level module. """ -from pkg_resources import DistributionNotFound, get_distribution +from importlib.metadata import PackageNotFoundError, version from . import postprocess, tutorial from .accessors import WRFDataArrayAccessor, WRFDatasetAccessor @@ -10,6 +10,6 @@ from .version_report import show_versions try: - __version__ = get_distribution(__name__).version -except DistributionNotFound: # pragma: no cover + __version__ = version(__name__) +except PackageNotFoundError: # pragma: no cover __version__ = 'unknown' # pragma: no cover