Skip to content

Commit

Permalink
test_bad_chunk_encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
brokkoli71 committed Feb 15, 2025
1 parent 0e227e0 commit de83f92
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,30 @@ async def test_v2_chunk_encoding(
assert arr.compressors == compressor_expected
assert arr.filters == filters_expected

@staticmethod
async def test_bad_chunk_encoding(store: MemoryStore) -> None:
"""
Test that passing an invalid compressor or filter to create_array raises an error.
"""
bad_compressor = 2
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."
with pytest.raises(ValueError, match=msg):
await create_array(
store=store,
dtype="uint8",
shape=(10,),
zarr_format=2,
compressors=bad_compressor, # type: ignore[arg-type]
)
with pytest.raises(KeyError):
await create_array(
store=store,
dtype="uint8",
shape=(10,),
zarr_format=3,
filters="bad_filter",
)

@staticmethod
@pytest.mark.parametrize("dtype", ["uint8", "float32", "str"])
async def test_default_filters_compressors(
Expand Down

0 comments on commit de83f92

Please sign in to comment.