From adfc9a8fd44d5b42c3842f6f75702e9f31d43bb9 Mon Sep 17 00:00:00 2001 From: Davis Vann Bennett Date: Tue, 1 Dec 2026 11:08:33 +0100 Subject: [PATCH] test(v2): ignore numcodecs' Pickle deprecation warning in pickle tests numcodecs main now warns that its Pickle codec is deprecated whenever one is created, and the suite turns warnings into errors, so the pickle decode-gate tests in test_v2.py fail in the upstream-dependencies job. Those tests create Pickle codecs on purpose, so ignore that warning for them. Released numcodecs doesn't warn, so the filter ignores the warning rather than requiring it. Assisted-by: ClaudeCode:claude-opus-5-5 --- tests/test_v2.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_v2.py b/tests/test_v2.py index 1fd1bd2288..54ef3abb43 100644 --- a/tests/test_v2.py +++ b/tests/test_v2.py @@ -325,6 +325,15 @@ def test_other_dtype_roundtrip(fill_value: bytes | None, tmp_path: Path) -> None assert (a == za[:]).all() +# numcodecs deprecates its Pickle codec and warns whenever one is created +# (zarr-developers/numcodecs#905). These tests create Pickle codecs on purpose to check zarr's +# decode gate, so the warning is expected. numcodecs versions without that deprecation don't +# emit it, so the filter ignores the warning rather than requiring it. +ignore_pickle_deprecation = pytest.mark.filterwarnings( + "ignore:The Pickle codec is deprecated:DeprecationWarning" +) + + def _pickle_compressed_array() -> zarr.Array[Any]: # Writing with the pickle codec is allowed without opting in, only decoding is gated. arr = zarr.create_array( @@ -351,6 +360,7 @@ def allow_numcodecs_unpickle(monkeypatch: pytest.MonkeyPatch) -> None: monkeypatch.setattr(numcodecs.pickles, "ALLOW_UNSAFE_PICKLE_DECODE", True) +@ignore_pickle_deprecation def test_pickle_codec_read_disabled_by_default() -> None: """Reading data encoded with the pickle codec fails unless the user opts in.""" arr = _pickle_compressed_array() @@ -362,6 +372,7 @@ def test_pickle_codec_read_disabled_by_default() -> None: assert "ALLOW_UNSAFE_PICKLE_DECODE" in str(excinfo.value) +@ignore_pickle_deprecation def test_pickle_codec_read_does_not_unpickle() -> None: """A malicious chunk is not unpickled when the pickle codec is disabled.""" @@ -389,6 +400,7 @@ def __reduce__(self) -> tuple[Any, ...]: arr[:] +@ignore_pickle_deprecation def test_pickle_codec_zarr_opt_in_does_not_bypass_numcodecs( monkeypatch: pytest.MonkeyPatch, ) -> None: @@ -402,6 +414,7 @@ def test_pickle_codec_zarr_opt_in_does_not_bypass_numcodecs( arr[:] +@ignore_pickle_deprecation @pytest.mark.usefixtures("allow_numcodecs_unpickle") def test_pickle_codec_read_enabled_via_config() -> None: arr = _pickle_compressed_array() @@ -409,6 +422,7 @@ def test_pickle_codec_read_enabled_via_config() -> None: np.testing.assert_array_equal(arr[:], np.array(["a", "bb", "ccc"])) +@ignore_pickle_deprecation @pytest.mark.usefixtures("allow_numcodecs_unpickle") @pytest.mark.parametrize(("env_value", "allowed"), [("True", True), ("false", False)]) def test_pickle_codec_read_enabled_via_env_var(