11from __future__ import annotations
22
3+ import itertools
4+
35import pytest
46
57from zarr .core .buffer import Buffer , cpu , gpu
68from zarr .storage .memory import GpuMemoryStore , MemoryStore
79from zarr .testing .store import StoreTests
810from zarr .testing .utils import gpu_test
911
12+ memory_store_kwargs = tuple (itertools .product ((None , True ), ("" , "foo" )))
13+
1014
1115class 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