Skip to content

Commit e68a341

Browse files
committed
parameterize over path in memorystore tests
1 parent 346d291 commit e68a341

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

tests/test_store/test_memory.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
from __future__ import annotations
22

3+
import itertools
4+
35
import pytest
46

57
from zarr.core.buffer import Buffer, cpu, gpu
68
from zarr.storage.memory import GpuMemoryStore, MemoryStore
79
from zarr.testing.store import StoreTests
810
from zarr.testing.utils import gpu_test
911

12+
memory_store_kwargs = tuple(itertools.product((None, True), ("", "foo")))
13+
1014

1115
class TestMemoryStore(StoreTests[MemoryStore, cpu.Buffer]):
1216
store_cls = MemoryStore
@@ -18,19 +22,17 @@ async def set(self, store: MemoryStore, key: str, value: Buffer) -> None:
1822
async def get(self, store: MemoryStore, key: str) -> Buffer:
1923
return store._store_dict[store.resolve_key(key)]
2024

21-
@pytest.fixture(params=[None, True])
25+
@pytest.fixture(params=memory_store_kwargs)
2226
def store_kwargs(
2327
self, request: pytest.FixtureRequest
2428
) -> dict[str, str | None | dict[str, Buffer]]:
25-
kwargs = {"store_dict": None, "mode": "r+", "path": ""}
26-
if request.param is True:
29+
store_dict_req, path = request.param
30+
kwargs = {"store_dict": store_dict_req, "mode": "r+", "path": path}
31+
if store_dict_req is True:
32+
# use a new empty dict each invocation of the function
2733
kwargs["store_dict"] = {}
2834
return kwargs
2935

30-
@pytest.fixture
31-
def store(self, store_kwargs: str | None | dict[str, Buffer]) -> MemoryStore:
32-
return self.store_cls(**store_kwargs)
33-
3436
def test_store_repr(self, store: MemoryStore) -> None:
3537
assert str(store) == f"memory://{id(store._store_dict)}"
3638

0 commit comments

Comments
 (0)