From 2cbda91a901a2ed09dcf8adf9a593fa461f2e726 Mon Sep 17 00:00:00 2001 From: Aniket Singh Rawat Date: Mon, 13 Jan 2025 00:36:28 +0530 Subject: [PATCH] Add test for other modes --- tests/test_api.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/test_api.py b/tests/test_api.py index aacd558f2a..2a384b5b3f 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -1086,10 +1086,14 @@ async def test_open_falls_back_to_open_group_async() -> None: assert group.attrs == {"key": "value"} -def test_open_mode_write_creates_group(tmp_path: pathlib.Path) -> None: +@pytest.mark.parametrize("mode", ["w", "a"]) +def test_open_write_modes_creates_group(tmp_path: pathlib.Path, mode: str) -> None: # https://github.com/zarr-developers/zarr-python/issues/2490 - zarr_dir = tmp_path / "test.zarr" - group = zarr.open(zarr_dir, mode="w") + zarr_dir = tmp_path / f"{mode}-test.zarr" + if mode in ["r", "r+"]: + # If read modes, create a zarr store first. + zarr.open(zarr_dir, mode="w") + group = zarr.open(zarr_dir, mode=mode) assert isinstance(group, Group)