Skip to content

Commit f04145c

Browse files
committed
Improve test coverage
1 parent 90cc08d commit f04145c

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/zarr/storage/_common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,9 @@ async def make_store_path(
321321
if not isinstance(store_like, FSMap):
322322
raise (TypeError(f"Unsupported type for store_like: '{type(store_like).__name__}'"))
323323
if path:
324-
raise TypeError("'path' was provided but is not used for FSMap store_like objects")
324+
raise ValueError("'path' was provided but is not used for FSMap store_like objects")
325325
if storage_options:
326-
raise TypeError(
326+
raise ValueError(
327327
"'storage_options was provided but is not used for FSMap store_like objects"
328328
)
329329
store = FsspecStore.from_mapper(store_like, read_only=_read_only)

tests/test_store/test_fsspec.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,22 @@ def test_open_s3map() -> None:
118118
z2[:] = 3
119119

120120

121+
def test_open_s3map_raises() -> None:
122+
with pytest.raises(TypeError, match="Unsupported type for store_like:.*"):
123+
zarr.open(store=0, mode="w", shape=(3, 3))
124+
s3_filesystem = s3fs.S3FileSystem(asynchronous=True, endpoint_url=endpoint_url, anon=False)
125+
mapper = s3_filesystem.get_mapper(f"s3://{test_bucket_name}/map/foo/")
126+
with pytest.raises(
127+
ValueError, match="'path' was provided but is not used for FSMap store_like objects"
128+
):
129+
zarr.open(store=mapper, mode="w", shape=(3, 3), path="foo")
130+
with pytest.raises(
131+
ValueError,
132+
match="'storage_options was provided but is not used for FSMap store_like objects",
133+
):
134+
zarr.open(store=mapper, mode="w", shape=(3, 3), storage_options={"anon": True})
135+
136+
121137
class TestFsspecStoreS3(StoreTests[FsspecStore, cpu.Buffer]):
122138
store_cls = FsspecStore
123139
buffer_cls = cpu.Buffer

0 commit comments

Comments
 (0)