Skip to content

Commit dd0de05

Browse files
committed
Specify abstract methods for StoreTests
1 parent 0792fa8 commit dd0de05

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

src/zarr/testing/store.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import asyncio
44
import pickle
5+
from abc import abstractmethod
56
from typing import TYPE_CHECKING, Generic, TypeVar
67

78
from zarr.storage import WrapperStore
@@ -37,26 +38,41 @@ class StoreTests(Generic[S, B]):
3738
store_cls: type[S]
3839
buffer_cls: type[B]
3940

41+
@abstractmethod
4042
async def set(self, store: S, key: str, value: Buffer) -> None:
4143
"""
4244
Insert a value into a storage backend, with a specific key.
4345
This should not not use any store methods. Bypassing the store methods allows them to be
4446
tested.
4547
"""
46-
raise NotImplementedError
48+
...
4749

50+
@abstractmethod
4851
async def get(self, store: S, key: str) -> Buffer:
4952
"""
5053
Retrieve a value from a storage backend, by key.
5154
This should not not use any store methods. Bypassing the store methods allows them to be
5255
tested.
5356
"""
57+
...
5458

55-
raise NotImplementedError
56-
59+
@abstractmethod
5760
@pytest.fixture
5861
def store_kwargs(self) -> dict[str, Any]:
59-
return {"read_only": False}
62+
"""Kwargs for instantiating a store"""
63+
...
64+
65+
@abstractmethod
66+
def test_store_repr(self, store: S) -> None: ...
67+
68+
@abstractmethod
69+
def test_store_supports_writes(self, store: S) -> None: ...
70+
71+
@abstractmethod
72+
def test_store_supports_partial_writes(self, store: S) -> None: ...
73+
74+
@abstractmethod
75+
def test_store_supports_listing(self, store: S) -> None: ...
6076

6177
@pytest.fixture
6278
def open_kwargs(self, store_kwargs: dict[str, Any]) -> dict[str, Any]:
@@ -122,18 +138,6 @@ async def test_read_only_store_raises(self, open_kwargs: dict[str, Any]) -> None
122138
with pytest.raises(ValueError):
123139
await store.delete("foo")
124140

125-
def test_store_repr(self, store: S) -> None:
126-
raise NotImplementedError
127-
128-
def test_store_supports_writes(self, store: S) -> None:
129-
raise NotImplementedError
130-
131-
def test_store_supports_partial_writes(self, store: S) -> None:
132-
raise NotImplementedError
133-
134-
def test_store_supports_listing(self, store: S) -> None:
135-
raise NotImplementedError
136-
137141
@pytest.mark.parametrize("key", ["c/0", "foo/c/0.0", "foo/0/0"])
138142
@pytest.mark.parametrize("data", [b"\x01\x02\x03\x04", b""])
139143
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)