@@ -454,60 +454,35 @@ def test_string_codecs() -> None:
454454
455455
456456def test_codec_requires_endian () -> None :
457- with pytest .raises (
458- ValueError ,
459- match = "Expected bytes codec to specify argument endian for data types for which endianness is applicable." ,
460- ):
457+ raise_msg = "The `endian` configuration needs to be specified for multi-byte data types."
458+ bytes_codec_no_conf = [{"name" : "bytes" }]
459+ with pytest .raises (ValueError , match = raise_msg ):
461460 ArrayV3Metadata .from_dict (
462- default_metadata_dict (data_type = "int16" , codecs = [{ "name" : "bytes" }] )
461+ default_metadata_dict (data_type = "int16" , codecs = bytes_codec_no_conf )
463462 )
464-
465- with pytest .raises (
466- ValueError ,
467- match = "Expected bytes codec to specify argument endian for data types for which endianness is applicable." ,
468- ):
463+ bytes_codec_empty_conf = [{"name" : "bytes" , "configuration" : {}}]
464+ with pytest .raises (ValueError , match = raise_msg ):
469465 ArrayV3Metadata .from_dict (
470- default_metadata_dict (
471- data_type = "int16" , codecs = [{"name" : "bytes" , "configuration" : {}}]
472- )
466+ default_metadata_dict (data_type = "int16" , codecs = bytes_codec_empty_conf )
473467 )
474-
468+ bytes_codec_with_endian = [{ "name" : "bytes" , "configuration" : { "endian" : "little" }}]
475469 ArrayV3Metadata .from_dict (
476- default_metadata_dict (
477- data_type = "int16" , codecs = [{"name" : "bytes" , "configuration" : {"endian" : "little" }}]
478- )
470+ default_metadata_dict (data_type = "int16" , codecs = bytes_codec_with_endian )
479471 )
480-
472+ sharding_codec_with_endian = [
473+ {
474+ "name" : "sharding_indexed" ,
475+ "configuration" : {"chunk_shape" : (1 ,), "codecs" : bytes_codec_with_endian },
476+ }
477+ ]
481478 ArrayV3Metadata .from_dict (
482- default_metadata_dict (
483- data_type = "int16" ,
484- codecs = [
485- {
486- "name" : "sharding_indexed" ,
487- "configuration" : {
488- "chunk_shape" : (1 ,),
489- "codecs" : [{"name" : "bytes" , "configuration" : {"endian" : "little" }}]
490- },
491- }
492- ],
493- )
479+ default_metadata_dict (data_type = "int16" , codecs = sharding_codec_with_endian )
494480 )
481+ sharding_codec_no_endian = [
482+ {"name" : "sharding_indexed" , "configuration" : {"chunk_shape" : (1 ,)}}
483+ ]
495484
496- #TODO
497- with pytest .raises (
498- ValueError ,
499- match = "Expected bytes codec to specify argument endian for data types for which endianness is applicable." ,
500- ):
485+ with pytest .raises (ValueError , match = raise_msg ):
501486 ArrayV3Metadata .from_dict (
502- default_metadata_dict (
503- data_type = "int16" ,
504- codecs = [
505- {
506- "name" : "sharding_indexed" ,
507- "configuration" : {
508- "chunk_shape" : (1 ,),
509- },
510- }
511- ],
512- )
487+ default_metadata_dict (data_type = "int16" , codecs = sharding_codec_no_endian )
513488 )
0 commit comments