@@ -371,13 +371,28 @@ def test_chunks_initialized(test_cls: type[Array] | type[AsyncArray[Any]]) -> No
371371 assert observed == expected
372372
373373
374- def test_nbytes_stored ():
374+ def test_nbytes_stored () -> None :
375375 arr = zarr .create (shape = (100 ,), chunks = (10 ,), dtype = "i4" )
376376 result = arr .nbytes_stored ()
377- assert result == 366 # the size of the metadata document. This is a fragile test
377+ assert result == 366 # the size of the metadata document. This is a fragile test.
378378 arr [:50 ] = 1
379379 result = arr .nbytes_stored ()
380- assert result == 366
380+ assert result == 566 # the size with 5 chunks filled.
381+ arr [50 :] = 2
382+ result = arr .nbytes_stored ()
383+ assert result == 766 # the size with all chunks filled.
384+
385+
386+ async def test_nbytes_stored_async () -> None :
387+ arr = await zarr .api .asynchronous .create (shape = (100 ,), chunks = (10 ,), dtype = "i4" )
388+ result = await arr .nbytes_stored ()
389+ assert result == 366 # the size of the metadata document. This is a fragile test.
390+ await arr .setitem (slice (50 ), 1 )
391+ result = await arr .nbytes_stored ()
392+ assert result == 566 # the size with 5 chunks filled.
393+ await arr .setitem (slice (50 , 100 ), 2 )
394+ result = await arr .nbytes_stored ()
395+ assert result == 766 # the size with all chunks filled.
381396
382397
383398def test_default_fill_values () -> None :
0 commit comments