44from types import ModuleType
55from typing import TYPE_CHECKING
66
7- from zarr .common import ZarrFormat
7+ from _pytest .compat import LEGACY_PATH
8+
9+ from zarr .abc .store import Store
10+ from zarr .common import ChunkCoords , MemoryOrder , ZarrFormat
811from zarr .group import AsyncGroup
912
1013if TYPE_CHECKING :
1114 from typing import Any , Literal
1215import pathlib
1316from dataclasses import dataclass , field
1417
18+ import numpy as np
1519import pytest
1620
1721from zarr .store import LocalStore , MemoryStore , StorePath
@@ -26,40 +30,40 @@ def parse_store(
2630 if store == "memory" :
2731 return MemoryStore (mode = "w" )
2832 if store == "remote" :
29- return RemoteStore (mode = "w" )
33+ return RemoteStore (url = path , mode = "w" )
3034 raise AssertionError
3135
3236
3337@pytest .fixture (params = [str , pathlib .Path ])
34- def path_type (request ) :
38+ def path_type (request : pytest . FixtureRequest ) -> Any :
3539 return request .param
3640
3741
3842# todo: harmonize this with local_store fixture
3943@pytest .fixture
40- def store_path (tmpdir ) :
44+ def store_path (tmpdir : LEGACY_PATH ) -> StorePath :
4145 store = LocalStore (str (tmpdir ), mode = "w" )
4246 p = StorePath (store )
4347 return p
4448
4549
4650@pytest .fixture (scope = "function" )
47- def local_store (tmpdir ) :
51+ def local_store (tmpdir : LEGACY_PATH ) -> LocalStore :
4852 return LocalStore (str (tmpdir ), mode = "w" )
4953
5054
5155@pytest .fixture (scope = "function" )
52- def remote_store () :
53- return RemoteStore (mode = "w" )
56+ def remote_store (url : str ) -> RemoteStore :
57+ return RemoteStore (url , mode = "w" )
5458
5559
5660@pytest .fixture (scope = "function" )
57- def memory_store ():
61+ def memory_store () -> MemoryStore :
5862 return MemoryStore (mode = "w" )
5963
6064
6165@pytest .fixture (scope = "function" )
62- def store (request : str , tmpdir ) :
66+ def store (request : pytest . FixtureRequest , tmpdir : LEGACY_PATH ) -> Store :
6367 param = request .param
6468 return parse_store (param , str (tmpdir ))
6569
@@ -72,7 +76,7 @@ class AsyncGroupRequest:
7276
7377
7478@pytest .fixture (scope = "function" )
75- async def async_group (request : pytest .FixtureRequest , tmpdir ) -> AsyncGroup :
79+ async def async_group (request : pytest .FixtureRequest , tmpdir : LEGACY_PATH ) -> AsyncGroup :
7680 param : AsyncGroupRequest = request .param
7781
7882 store = parse_store (param .store , str (tmpdir ))
@@ -90,3 +94,20 @@ def xp(request: pytest.FixtureRequest) -> Iterator[ModuleType]:
9094 """Fixture to parametrize over numpy-like libraries"""
9195
9296 yield pytest .importorskip (request .param )
97+
98+
99+ @dataclass
100+ class ArrayRequest :
101+ shape : ChunkCoords
102+ dtype : str
103+ order : MemoryOrder
104+
105+
106+ @pytest .fixture
107+ def array_fixture (request : pytest .FixtureRequest ) -> np .ndarray :
108+ array_request : ArrayRequest = request .param
109+ return (
110+ np .arange (np .prod (array_request .shape ))
111+ .reshape (array_request .shape , order = array_request .order )
112+ .astype (array_request .dtype )
113+ )
0 commit comments