@@ -209,7 +209,7 @@ def test_save(store: Store, n_args: int, n_kwargs: int) -> None:
209209 assert isinstance (array , Array )
210210 assert_array_equal (array [:], data )
211211 else :
212- save (store , * args , ** kwargs ) # type: ignore[arg-type]
212+ save (store , * args , ** kwargs ) # type: ignore [arg-type]
213213 group = open (store )
214214 assert isinstance (group , Group )
215215 for array in group .array_values ():
@@ -1095,25 +1095,31 @@ async def test_open_falls_back_to_open_group_async() -> None:
10951095 assert group .attrs == {"key" : "value" }
10961096
10971097
1098- def test_open_mode_write_creates_group (tmp_path : pathlib .Path ) -> None :
1098+ @pytest .mark .parametrize ("mode" , ["r" , "r+" , "w" , "a" ])
1099+ def test_open_modes_creates_group (tmp_path : pathlib .Path , mode : str ) -> None :
10991100 # https://github.com/zarr-developers/zarr-python/issues/2490
1100- zarr_dir = tmp_path / "test.zarr"
1101- group = zarr .open (zarr_dir , mode = "w" )
1102- assert isinstance (group , Group )
1101+ zarr_dir = tmp_path / f"mode-{ mode } -test.zarr"
1102+ if mode in ["r" , "r+" ]:
1103+ # Expect FileNotFoundError to be raised if 'r' or 'r+' mode
1104+ with pytest .raises (FileNotFoundError ):
1105+ zarr .open (store = zarr_dir , mode = mode )
1106+ else :
1107+ group = zarr .open (store = zarr_dir , mode = mode )
1108+ assert isinstance (group , Group )
11031109
11041110
11051111async def test_metadata_validation_error () -> None :
11061112 with pytest .raises (
11071113 MetadataValidationError ,
11081114 match = "Invalid value for 'zarr_format'. Expected '2, 3, or None'. Got '3.0'." ,
11091115 ):
1110- await zarr .api .asynchronous .open_group (zarr_format = "3.0" ) # type: ignore[arg-type]
1116+ await zarr .api .asynchronous .open_group (zarr_format = "3.0" ) # type: ignore [arg-type]
11111117
11121118 with pytest .raises (
11131119 MetadataValidationError ,
11141120 match = "Invalid value for 'zarr_format'. Expected '2, 3, or None'. Got '3.0'." ,
11151121 ):
1116- await zarr .api .asynchronous .open_array (shape = (1 ,), zarr_format = "3.0" ) # type: ignore[arg-type]
1122+ await zarr .api .asynchronous .open_array (shape = (1 ,), zarr_format = "3.0" ) # type: ignore [arg-type]
11171123
11181124
11191125@pytest .mark .parametrize (
0 commit comments