Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for other modes #2690

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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+"]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block won't every be executed, because the mode is only 'w' or 'a' in this test. Do you think we should get rid of the if block, or extend the parameterisation to include 'r' and '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)


Expand Down
Loading