diff --git a/changes/2714.misc.rst b/changes/2714.misc.rst new file mode 100644 index 0000000000..9ab55089d2 --- /dev/null +++ b/changes/2714.misc.rst @@ -0,0 +1 @@ +Make warning filters in the tests more specific, so warnings emitted by tests added in the future are more likely to be caught instead of ignored. diff --git a/pyproject.toml b/pyproject.toml index d862cce0ac..1ee5678f82 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -397,12 +397,18 @@ addopts = [ "--durations=10", "-ra", "--strict-config", "--strict-markers", ] filterwarnings = [ - "error:::zarr.*", - "ignore:PY_SSIZE_T_CLEAN will be required.*:DeprecationWarning", - "ignore:The loop argument is deprecated since Python 3.8.*:DeprecationWarning", - "ignore:Creating a zarr.buffer.gpu.*:UserWarning", - "ignore:Duplicate name:UserWarning", # from ZipFile - "ignore:.*is currently not part in the Zarr format 3 specification.*:UserWarning", + "error", + # TODO: explicitly filter or catch the warnings below where we expect them to be emitted in the tests + "ignore:Consolidated metadata is currently not part in the Zarr format 3 specification.*:UserWarning", + "ignore:Creating a zarr.buffer.gpu.Buffer with an array that does not support the __cuda_array_interface__.*:UserWarning", + "ignore:Automatic shard shape inference is experimental and may change without notice.*:UserWarning", + "ignore:The codec .* is currently not part in the Zarr format 3 specification.*:UserWarning", + "ignore:The dtype .* is currently not part in the Zarr format 3 specification.*:UserWarning", + "ignore:Use zarr.create_array instead.:DeprecationWarning", + "ignore:Duplicate name.*:UserWarning", + "ignore:The `compressor` argument is deprecated. Use `compressors` instead.:UserWarning", + "ignore:Numcodecs codecs are not in the Zarr version 3 specification and may not be supported by other zarr implementations.:UserWarning", + "ignore:Unclosed client session None: store._is_open = True +# TODO: work out where warning is coming from and fix +@pytest.mark.filterwarnings( + "ignore:coroutine 'ClientCreatorContext.__aexit__' was never awaited:RuntimeWarning" +) @pytest.mark.parametrize("store", ["local", "memory", "zip"], indirect=True) async def test_wrapped_set(store: Store, capsys: pytest.CaptureFixture[str]) -> None: # define a class that prints when it sets @@ -89,6 +97,7 @@ async def set(self, key: str, value: Buffer) -> None: assert await store_wrapped.get(key, buffer_prototype) == value +@pytest.mark.filterwarnings("ignore:Unclosed client session:ResourceWarning") @pytest.mark.parametrize("store", ["local", "memory", "zip"], indirect=True) async def test_wrapped_get(store: Store, capsys: pytest.CaptureFixture[str]) -> None: # define a class that prints when it sets diff --git a/tests/test_store/test_zip.py b/tests/test_store/test_zip.py index 839656108b..0237258ab1 100644 --- a/tests/test_store/test_zip.py +++ b/tests/test_store/test_zip.py @@ -19,6 +19,14 @@ from typing import Any +# TODO: work out where this is coming from and fix +pytestmark = [ + pytest.mark.filterwarnings( + "ignore:coroutine method 'aclose' of 'ZipStore.list' was never awaited:RuntimeWarning" + ) +] + + class TestZipStore(StoreTests[ZipStore, cpu.Buffer]): store_cls = ZipStore buffer_cls = cpu.Buffer @@ -66,6 +74,8 @@ def test_store_supports_partial_writes(self, store: ZipStore) -> None: def test_store_supports_listing(self, store: ZipStore) -> None: assert store.supports_listing + # TODO: fix this warning + @pytest.mark.filterwarnings("ignore:Unclosed client session:ResourceWarning") def test_api_integration(self, store: ZipStore) -> None: root = zarr.open_group(store=store, mode="a") diff --git a/tests/test_sync.py b/tests/test_sync.py index e0002fc5a7..13b475f8da 100644 --- a/tests/test_sync.py +++ b/tests/test_sync.py @@ -90,6 +90,7 @@ def test_sync_raises_if_loop_is_closed() -> None: foo.assert_not_awaited() +@pytest.mark.filterwarnings("ignore:Unclosed client session:ResourceWarning") @pytest.mark.filterwarnings("ignore:coroutine.*was never awaited") def test_sync_raises_if_calling_sync_from_within_a_running_loop( sync_loop: asyncio.AbstractEventLoop | None,