Skip to content

Commit e740027

Browse files
Run delete nonexistent key test across all stores
1 parent 90c6c02 commit e740027

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/zarr/storage/_obstore.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff 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

src/zarr/testing/store.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff 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(

tests/test_store/test_object.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff 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
8380
def test_zarr_hierarchy():

0 commit comments

Comments
 (0)