1
1
# ruff: noqa: E402
2
- from typing import Any
2
+ from pathlib import Path
3
+ from typing import TypedDict
3
4
4
5
import pytest
5
6
16
17
from zarr .testing .store import StoreTests
17
18
18
19
20
+ class StoreKwargs (TypedDict ):
21
+ store : LocalStore
22
+ read_only : bool
23
+
24
+
19
25
class TestObjectStore (StoreTests [ObjectStore , cpu .Buffer ]):
20
26
store_cls = ObjectStore
21
27
buffer_cls = cpu .Buffer
22
28
23
29
@pytest .fixture
24
- def store_kwargs (self , tmpdir ) -> dict [ str , Any ] :
25
- store = LocalStore (prefix = tmpdir )
30
+ def store_kwargs (self , tmp_path : Path ) -> StoreKwargs :
31
+ store = LocalStore (prefix = tmp_path )
26
32
return {"store" : store , "read_only" : False }
27
33
28
34
@pytest .fixture
29
- def store (self , store_kwargs : dict [ str , str | bool ] ) -> ObjectStore :
35
+ def store (self , store_kwargs : StoreKwargs ) -> ObjectStore :
30
36
return self .store_cls (** store_kwargs )
31
37
32
38
async def get (self , store : ObjectStore , key : str ) -> Buffer :
@@ -48,10 +54,8 @@ def test_store_repr(self, store: ObjectStore) -> None:
48
54
def test_store_supports_writes (self , store : ObjectStore ) -> None :
49
55
assert store .supports_writes
50
56
51
- async def test_store_supports_partial_writes (self , store : ObjectStore ) -> None :
57
+ def test_store_supports_partial_writes (self , store : ObjectStore ) -> None :
52
58
assert not store .supports_partial_writes
53
- with pytest .raises (NotImplementedError ):
54
- await store .set_partial_values ([("foo" , 0 , b"\x01 \x02 \x03 \x04 " )])
55
59
56
60
def test_store_supports_listing (self , store : ObjectStore ) -> None :
57
61
assert store .supports_listing
@@ -64,6 +68,7 @@ def test_store_equal(self, store: ObjectStore) -> None:
64
68
new_memory_store = ObjectStore (MemoryStore ())
65
69
assert store != new_memory_store
66
70
# Test equality against a read only store
71
+ assert isinstance (store .store , LocalStore )
67
72
new_local_store = ObjectStore (LocalStore (prefix = store .store .prefix ), read_only = True )
68
73
assert store != new_local_store
69
74
# Test two memory stores cannot be equal
@@ -73,7 +78,7 @@ def test_store_equal(self, store: ObjectStore) -> None:
73
78
def test_store_init_raises (self ) -> None :
74
79
"""Test __init__ raises appropriate error for improper store type"""
75
80
with pytest .raises (TypeError ):
76
- ObjectStore ("path/to/store" )
81
+ ObjectStore ("path/to/store" ) # type: ignore[arg-type]
77
82
78
83
async def test_store_getsize (self , store : ObjectStore ) -> None :
79
84
buf = cpu .Buffer .from_bytes (b"\x01 \x02 \x03 \x04 " )
@@ -92,10 +97,10 @@ async def test_store_getsize_prefix(self, store: ObjectStore) -> None:
92
97
93
98
94
99
@pytest .mark .slow_hypothesis
95
- def test_zarr_hierarchy ():
100
+ def test_zarr_hierarchy () -> None :
96
101
sync_store = ObjectStore (MemoryStore ())
97
102
98
103
def mk_test_instance_sync () -> ZarrHierarchyStateMachine :
99
104
return ZarrHierarchyStateMachine (sync_store )
100
105
101
- run_state_machine_as_test (mk_test_instance_sync )
106
+ run_state_machine_as_test (mk_test_instance_sync ) # type: ignore[no-untyped-call]
0 commit comments