Skip to content

Commit 0792fa8

Browse files
committed
Test using stores in a context manager
1 parent 6923337 commit 0792fa8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/zarr/testing/store.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ async def test_store_open_read_only(self, open_kwargs: dict[str, Any], read_only
100100
assert store._is_open
101101
assert store.read_only == read_only
102102

103+
async def test_store_context_manager(self, open_kwargs: dict[str, Any]) -> None:
104+
# Test that the context manager closes the store
105+
with await self.store_cls.open(**open_kwargs) as store:
106+
assert store._is_open
107+
# Test trying to open an already open store
108+
with pytest.raises(ValueError):
109+
await store._open()
110+
assert not store._is_open
111+
103112
async def test_read_only_store_raises(self, open_kwargs: dict[str, Any]) -> None:
104113
kwargs = {**open_kwargs, "read_only": True}
105114
store = await self.store_cls.open(**kwargs)

0 commit comments

Comments
 (0)