File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -186,13 +186,16 @@ def supports_deletes(self) -> bool:
186186 async def delete (self , key : str ) -> None :
187187 # docstring inherited
188188 import obstore as obs
189+ from obstore .exceptions import NotFoundError
189190
190191 self ._check_writable ()
191192
192193 # Some stores such as local filesystems, GCP and Azure raise an error
193194 # when deleting a non-existent key, while others such as S3 and in-memory do
194195 # not. We suppress the error to make the behavior consistent across all stores
195- with contextlib .suppress (FileNotFoundError ):
196+ # currently obstore raises FileNotFoundError, but in the future might raise
197+ # NotFoundError instead, so let's suppress that too
198+ with contextlib .suppress (FileNotFoundError , NotFoundError ):
196199 await obs .delete_async (self .store , key )
197200
198201 @property
Original file line number Diff line number Diff line change @@ -401,6 +401,11 @@ async def test_delete_dir(self, store: S) -> None:
401401 assert not await store .exists ("foo/zarr.json" )
402402 assert not await store .exists ("foo/c/0" )
403403
404+ async def test_delete_nonexistent_key_does_not_raise (self , store : S ) -> None :
405+ if not store .supports_deletes :
406+ pytest .skip ("store does not support deletes" )
407+ await store .delete ("nonexistent_key" )
408+
404409 async def test_is_empty (self , store : S ) -> None :
405410 assert await store .is_empty ("" )
406411 await self .set (
Original file line number Diff line number Diff line change @@ -75,9 +75,6 @@ def test_store_init_raises(self) -> None:
7575 with pytest .raises (TypeError ):
7676 ObjectStore ("path/to/store" )
7777
78- async def test_store_delete_nonexistent_key_does_not_raise (self , store : ObjectStore ) -> None :
79- await store .delete ("nonexistent_key" )
80-
8178
8279@pytest .mark .slow_hypothesis
8380def test_zarr_hierarchy ():
You can’t perform that action at this time.
0 commit comments