Skip to content

Commit 253510b

Browse files
trexfeathersweb-flowESadek-MO
authored
Update lock files plus test fixes (#7270)
* Updated environment lockfiles * Temporary gallery test fix. * Revert "Temporary gallery test fix." This reverts commit 6403701. * Skip Proj 9.8 incompatible gallery tests. Proven by 6403701. * Modernise graphics tests. * What's New entry. --------- Co-authored-by: Lockfile bot <noreply@github.com> Co-authored-by: Elias <110238618+ESadek-MO@users.noreply.github.com>
1 parent d9ebbaf commit 253510b

8 files changed

Lines changed: 578 additions & 527 deletions

File tree

changelog/7270.dependency

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
:user:`trexfeathers` modernised the Iris gallery tests, and set several to skip
2+
if using the incompatible combination of PROJ>=9.8 and Cartopy<0.26.

docs/gallery_tests/conftest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212

1313
import iris
1414

15+
pytest_plugins = ["iris.tests.conftest"]
16+
17+
1518
CURRENT_DIR = pathlib.Path(__file__).resolve()
1619
GALLERY_DIR = CURRENT_DIR.parents[1] / "gallery_code"
1720

docs/gallery_tests/test_gallery_examples.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
import matplotlib.pyplot as plt
1111
import pytest
1212

13-
from iris.tests import _RESULT_PATH
14-
from iris.tests.graphics import check_graphic
13+
from iris.tests import _shared_utils
1514

1615
from .conftest import GALLERY_DIR
1716

@@ -29,8 +28,19 @@ def test_plot_example(
2928
image_setup_teardown,
3029
import_patches,
3130
iris_future_defaults,
31+
check_graphic_caller,
3232
):
3333
"""Test that all figures from example code match KGO."""
34+
if example in (
35+
"plot_TEC",
36+
"plot_orca_projection",
37+
"plot_projections_and_annotations",
38+
):
39+
proj_9_8_message = _shared_utils.proj_9_8_incompatible_message()
40+
incompatible = proj_9_8_message != ""
41+
if incompatible:
42+
pytest.skip(proj_9_8_message)
43+
3444
module = importlib.import_module(example)
3545

3646
# Run example.
@@ -39,5 +49,4 @@ def test_plot_example(
3949
# will find it.
4050
for fig_num in plt.get_fignums():
4151
plt.figure(fig_num)
42-
image_id = f"gallery_tests.test_{example}.{fig_num - 1}"
43-
check_graphic(image_id, _RESULT_PATH)
52+
check_graphic_caller()

lib/iris/tests/_shared_utils.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,15 +1024,12 @@ def env_bin_path(exe_name: Optional[str] = None):
10241024
return exe_path
10251025

10261026

1027-
# TODO: Remove this decorator once problematic versions have been phased out
1028-
def skip_proj_9_8_incompatible(func: Callable):
1029-
"""A decorator that skips decorated tests when PROJ is >=9.8 and Cartopy is <0.26.
1027+
# TODO: Remove this convenience once problematic versions have been phased out
1028+
def proj_9_8_incompatible_message() -> str:
1029+
"""Return a message if Cartopy is <0.26 and PROJ is >=9.8, otherwise return an empty string.
10301030
10311031
Cartopy v0.26 addresses a known incompatibility with PROJ v9.8:
10321032
https://github.com/SciTools/cartopy/pull/2653
1033-
1034-
Implemented as a callable to avoid wasteful top-level import of these
1035-
packages - _shared_utils is imported by every test module.
10361033
"""
10371034
import cartopy
10381035
from packaging.version import Version
@@ -1042,9 +1039,25 @@ def skip_proj_9_8_incompatible(func: Callable):
10421039
proj_version = Version(pyproj.__proj_version__)
10431040

10441041
incompatible = proj_version >= Version("9.8") and cartopy_version < Version("0.26")
1042+
if incompatible:
1043+
result = "Cartopy<0.26 is incompatible with PROJ>=9.8. SciTools/cartopy#2653"
1044+
else:
1045+
result = ""
1046+
return result
1047+
1048+
1049+
# TODO: Remove this decorator once problematic versions have been phased out
1050+
def skip_proj_9_8_incompatible(func: Callable):
1051+
"""A decorator that skips decorated tests when PROJ is >=9.8 and Cartopy is <0.26.
1052+
1053+
Implemented as a callable to avoid wasteful top-level import of these
1054+
packages - _shared_utils is imported by every test module.
1055+
"""
1056+
message = proj_9_8_incompatible_message()
1057+
incompatible = message != ""
10451058
skip = pytest.mark.skipif(
10461059
incompatible,
1047-
reason="Cartopy<0.26 is incompatible with PROJ>=9.8. SciTools/cartopy#2653",
1060+
reason=message,
10481061
)
10491062
return skip(func)
10501063

lib/iris/tests/conftest.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,20 @@ def _unique_id(request: pytest.FixtureRequest, test_call_counter) -> Callable:
3636
Used by :func:`iris.tests.graphics.check_graphic_caller` to ensure unique
3737
image names.
3838
"""
39-
id_sequence = [request.module.__name__, request.node.originalname]
39+
# Backwards compatibility for existing gallery result naming.
40+
gallery_compat = request.module.__name__.startswith("gallery_tests.")
41+
42+
if gallery_compat:
43+
id_sequence = ["gallery_tests"]
44+
else:
45+
id_sequence = [request.module.__name__, request.node.originalname]
4046
if request.cls is not None:
4147
id_sequence.insert(-1, request.cls.__name__)
4248
if hasattr(request.node, "callspec"):
43-
id_sequence.append(request.node.callspec.id)
49+
callspec_id = request.node.callspec.id
50+
if gallery_compat:
51+
callspec_id = f"test_{callspec_id}"
52+
id_sequence.append(callspec_id)
4453
test_id = ".".join(id_sequence)
4554

4655
def generate_id():

requirements/locks/py312-linux-64.lock

Lines changed: 183 additions & 176 deletions
Large diffs are not rendered by default.

requirements/locks/py313-linux-64.lock

Lines changed: 183 additions & 176 deletions
Large diffs are not rendered by default.

requirements/locks/py314-linux-64.lock

Lines changed: 163 additions & 162 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)