Skip to content

Commit ef37b33

Browse files
committed
Test v2 array w/ v3 codec errors
1 parent 4930ad1 commit ef37b33

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/test_api.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from typing import TYPE_CHECKING
44

5+
import zarr.codecs
6+
57
if TYPE_CHECKING:
68
import pathlib
79

@@ -1196,3 +1198,14 @@ def test_v2_without_copmpressor() -> None:
11961198
# Make sure it's possible to set no compressor for v2 arrays
11971199
arr = zarr.create(store={}, shape=(1), dtype="uint8", zarr_format=2, compressor=None)
11981200
assert arr.compressors == ()
1201+
1202+
1203+
def test_v2_with_v3_copmpressor() -> None:
1204+
# Check trying to create a v2 array with a v3 compressor fails
1205+
with pytest.raises(
1206+
ValueError,
1207+
match="Cannot use a BytesBytesCodec as a compressor for zarr v2 arrays. Use a numcodecs codec directly instead.",
1208+
):
1209+
zarr.create(
1210+
store={}, shape=(1), dtype="uint8", zarr_format=2, compressor=zarr.codecs.BloscCodec()
1211+
)

0 commit comments

Comments
 (0)