@@ -581,20 +581,30 @@ async def test_consolidated_metadata_encodes_special_chars(
581581 memory_store : Store , zarr_format : ZarrFormat , fill_value : float
582582):
583583 root = await group (store = memory_store , zarr_format = zarr_format )
584+ _child = await root .create_group ("child" , attributes = {"test" : fill_value })
584585 _time = await root .create_array ("time" , shape = (12 ,), dtype = np .float64 , fill_value = fill_value )
585586 await zarr .api .asynchronous .consolidate_metadata (memory_store )
586587
587588 root = await group (store = memory_store , zarr_format = zarr_format )
588589 root_buffer = root .metadata .to_buffer_dict (default_buffer_prototype ())
589590
590591 if zarr_format == 2 :
591- root_metadata = root_buffer [".zmetadata" ].to_bytes ().decode ("utf-8" )
592+ root_metadata = json . loads ( root_buffer [".zmetadata" ].to_bytes ().decode ("utf-8" ))[ "metadata" ]
592593 elif zarr_format == 3 :
593- root_metadata = root_buffer ["zarr.json" ].to_bytes ().decode ("utf-8" )
594+ root_metadata = json .loads (root_buffer ["zarr.json" ].to_bytes ().decode ("utf-8" ))[
595+ "consolidated_metadata"
596+ ]["metadata" ]
594597
595598 if np .isnan (fill_value ):
596- assert ' "NaN"' in root_metadata
599+ expected_fill_value = "NaN"
597600 elif np .isneginf (fill_value ):
598- assert ' "-Infinity"' in root_metadata
601+ expected_fill_value = "-Infinity"
599602 elif np .isinf (fill_value ):
600- assert '"Infinity"' in root_metadata
603+ expected_fill_value = "Infinity"
604+
605+ if zarr_format == 2 :
606+ assert root_metadata ["child/.zattrs" ]["test" ] == expected_fill_value
607+ assert root_metadata ["time/.zarray" ]["fill_value" ] == expected_fill_value
608+ elif zarr_format == 3 :
609+ assert root_metadata ["child" ]["attributes" ]["test" ] == expected_fill_value
610+ assert root_metadata ["time" ]["fill_value" ] == expected_fill_value
0 commit comments