|
45 | 45 | from zarr.core.buffer import NDArrayLike |
46 | 46 | from zarr.errors import ( |
47 | 47 | ArrayNotFoundError, |
| 48 | + GroupNotFoundError, |
48 | 49 | MetadataValidationError, |
49 | 50 | ZarrDeprecationWarning, |
50 | 51 | ZarrUserWarning, |
@@ -1547,3 +1548,33 @@ def test_unimplemented_kwarg_warnings(kwarg_name: str) -> None: |
1547 | 1548 | kwargs = {kwarg_name: 1} |
1548 | 1549 | with pytest.warns(RuntimeWarning, match=".* is not yet implemented"): |
1549 | 1550 | zarr.create(shape=(1,), **kwargs) # type: ignore[arg-type] |
| 1551 | + |
| 1552 | + |
| 1553 | +def test_specific_fmt_error_message_group() -> None: |
| 1554 | + store = zarr.storage.MemoryStore() |
| 1555 | + # Create a group |
| 1556 | + zarr.create_group(store=store, path="my_group", zarr_format=3) |
| 1557 | + # Check that the new group exists |
| 1558 | + zarr.open_group(store=store, path="my_group", mode="r", zarr_format=3) |
| 1559 | + # Check error message when opening with wrong Zarr format |
| 1560 | + with pytest.raises(GroupNotFoundError, match="No Zarr 2 group found"): |
| 1561 | + zarr.open_group(store=store, path="my_group", mode="r", zarr_format=2) |
| 1562 | + |
| 1563 | + |
| 1564 | +def test_specific_fmt_error_message_array() -> None: |
| 1565 | + store = zarr.storage.MemoryStore() |
| 1566 | + # Create an array |
| 1567 | + zarr.create_array( |
| 1568 | + store=store, |
| 1569 | + zarr_format=3, |
| 1570 | + data=np.array( |
| 1571 | + [ |
| 1572 | + 1, |
| 1573 | + ] |
| 1574 | + ), |
| 1575 | + ) |
| 1576 | + # Check that the new array exists |
| 1577 | + zarr.open_array(store=store, mode="r", zarr_format=3) |
| 1578 | + # Check error message when opening with wrong Zarr format |
| 1579 | + with pytest.raises(ArrayNotFoundError, match="No Zarr 2 array found"): |
| 1580 | + zarr.open_array(store=store, mode="r", zarr_format=2) |
0 commit comments