From ef7863a0077475b623d661e2c6e744adf1340a1c Mon Sep 17 00:00:00 2001 From: Davis Vann Bennett Date: Mon, 13 Jul 2026 17:39:42 +0200 Subject: [PATCH] test: ignore Python 3.15 fork-with-threads DeprecationWarning in test_multiprocessing Python 3.15 makes os.fork() emit a DeprecationWarning when the process has multiple threads (python/cpython#84559). zarr's sync event-loop thread is always running by the time test_multiprocessing forks, and the suite runs with filterwarnings = ["error"], so the fork parametrizations fail on 3.15. Fork-safety despite those threads is exactly what this test pins down (zarr registers an os.register_at_fork handler), so keep the coverage and ignore the warning with a targeted per-param filter. Fixes #4086 Assisted-by: ClaudeCode:claude-fable-5 --- changes/4086.misc.md | 1 + tests/test_array.py | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 changes/4086.misc.md diff --git a/changes/4086.misc.md b/changes/4086.misc.md new file mode 100644 index 0000000000..2564cf9ea1 --- /dev/null +++ b/changes/4086.misc.md @@ -0,0 +1 @@ +Fix `test_multiprocessing[fork]` failing on Python 3.15, where `os.fork()` in a multi-threaded process emits a `DeprecationWarning` that the test suite promotes to an error. diff --git a/tests/test_array.py b/tests/test_array.py index 89d7547e78..a9fa07ceef 100644 --- a/tests/test_array.py +++ b/tests/test_array.py @@ -1902,9 +1902,18 @@ def _index_array(arr: AnyArray, index: Any) -> Any: [ pytest.param( "fork", - marks=pytest.mark.skipif( - sys.platform in ("win32", "darwin"), reason="fork not supported on Windows or OSX" - ), + marks=[ + pytest.mark.skipif( + sys.platform in ("win32", "darwin"), + reason="fork not supported on Windows or OSX", + ), + # Python 3.15 deprecates fork() in multi-threaded processes, and zarr's + # sync event-loop thread is always running here. Fork-safety despite + # those threads is exactly what this test pins down, so keep running it. + pytest.mark.filterwarnings( + r"ignore:This process \(pid=\d+\) is multi-threaded, use of fork\(\):DeprecationWarning" + ), + ], ), "spawn", pytest.param(