Skip to content

Commit de83f92

Browse files
committed
test_bad_chunk_encoding
1 parent 0e227e0 commit de83f92

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/test_array.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,30 @@ async def test_v2_chunk_encoding(
11541154
assert arr.compressors == compressor_expected
11551155
assert arr.filters == filters_expected
11561156

1157+
@staticmethod
1158+
async def test_bad_chunk_encoding(store: MemoryStore) -> None:
1159+
"""
1160+
Test that passing an invalid compressor or filter to create_array raises an error.
1161+
"""
1162+
bad_compressor = 2
1163+
msg = f"For Zarr format 2 arrays, the `compressor` must be a single codec. Expected None, a numcodecs.abc.Codec, or a dict or str representation of a numcodecs.abc.Codec. Got {type(bad_compressor)} instead."
1164+
with pytest.raises(ValueError, match=msg):
1165+
await create_array(
1166+
store=store,
1167+
dtype="uint8",
1168+
shape=(10,),
1169+
zarr_format=2,
1170+
compressors=bad_compressor, # type: ignore[arg-type]
1171+
)
1172+
with pytest.raises(KeyError):
1173+
await create_array(
1174+
store=store,
1175+
dtype="uint8",
1176+
shape=(10,),
1177+
zarr_format=3,
1178+
filters="bad_filter",
1179+
)
1180+
11571181
@staticmethod
11581182
@pytest.mark.parametrize("dtype", ["uint8", "float32", "str"])
11591183
async def test_default_filters_compressors(

0 commit comments

Comments
 (0)