Skip to content

Commit 9ec0d01

Browse files
committed
revert store fixture name convention
1 parent 2ab4dc3 commit 9ec0d01

File tree

3 files changed

+47
-56
lines changed

3 files changed

+47
-56
lines changed

tests/conftest.py

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from zarr.storage.remote import RemoteStore
1919

2020
if TYPE_CHECKING:
21-
from collections.abc import Generator
21+
from collections.abc import Generator, AsyncGenerator
2222
from typing import Any, Literal
2323

2424
import botocore
@@ -42,30 +42,21 @@ async def parse_store(
4242
s3: s3fs.S3FileSystem, # type: ignore[name-defined]
4343
) -> LocalStore | MemoryStore | RemoteStore | ZipStore:
4444
"""
45-
Take a string representation of a store + access mode, e.g. 'local_a', which would encode
46-
LocalStore + access mode `a`, and convert that string representation into the appropriate store object,
47-
which is then returned.
45+
Take a string representation of a store and convert that string representation
46+
into the appropriate store object, which is then returned.
4847
"""
49-
store_parsed = store.split("_")
50-
51-
if len(store_parsed) == 1:
52-
store_type = store_parsed[0]
53-
# the default mode for testing is a
54-
mode = "a"
55-
elif len(store_parsed) == 2:
56-
store_type, mode = store_parsed
57-
else:
58-
raise ValueError(f"Invalid store specification: {store}")
59-
60-
match store_type:
48+
49+
match store:
6150
case "local":
62-
return await LocalStore.open(path, mode=mode)
51+
return LocalStore(path, read_only=False)
6352
case "memory":
64-
return await MemoryStore.open(mode=mode)
53+
return MemoryStore(read_only=False)
6554
case "remote":
66-
return await RemoteStore.open(fs=s3, path=test_bucket_name, mode=mode)
55+
return RemoteStore(fs=s3, path=test_bucket_name, read_only=False)
6756
case "zip":
68-
return await ZipStore.open(path + "/zarr.zip", mode=mode)
57+
_store = await ZipStore.open(path + "/zarr.zip", read_only=False, mode='w')
58+
return _store
59+
6960
raise AssertionError
7061

7162

@@ -86,9 +77,11 @@ async def store(
8677
request: pytest.FixtureRequest,
8778
tmpdir: LEGACY_PATH,
8879
s3: s3fs.S3FileSystem, # type: ignore[name-defined]
89-
) -> Store:
80+
) -> AsyncGenerator[Store, None, None]:
9081
param = request.param
91-
return await parse_store(param, str(tmpdir), s3)
82+
store_instance = await parse_store(param, str(tmpdir), s3)
83+
yield store_instance
84+
store_instance.close()
9285

9386

9487
@pytest.fixture(params=["local", "memory", "zip"])

tests/test_api.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from zarr.storage.zip import ZipStore
2929

3030

31-
@pytest.mark.parametrize("store", ["local_a", "memory_a", "remote_a", "zip_a"], indirect=True)
31+
@pytest.mark.parametrize("store", ["local", "memory", "remote"], indirect=True)
3232
def test_create_array(store: Store) -> None:
3333
# create array
3434
z = create(shape=100, store=store)
@@ -48,7 +48,7 @@ def test_create_array(store: Store) -> None:
4848
assert z.chunks == (40,)
4949

5050

51-
@pytest.mark.parametrize("store", ["local_a", "memory_a", "remote_a", "zip_a"], indirect=True)
51+
@pytest.mark.parametrize("store", ["local", "memory", "remote", "zip"], indirect=True)
5252
@pytest.mark.parametrize("path", ["foo", "/", "/foo", "///foo/bar"])
5353
@pytest.mark.parametrize("node_type", ["array", "group"])
5454
def test_open_normalized_path(
@@ -63,7 +63,7 @@ def test_open_normalized_path(
6363
assert node.path == normalize_path(path)
6464

6565

66-
@pytest.mark.parametrize("store", ["local_a", "memory_a", "remote_a", "zip_a"], indirect=True)
66+
@pytest.mark.parametrize("store", ["local", "memory", "remote", "zip"], indirect=True)
6767
async def test_open_array(store: Store, zarr_format: ZarrFormat) -> None:
6868
# open array, create if doesn't exist
6969
z = open(store=store, shape=100, zarr_format=zarr_format)
@@ -101,7 +101,7 @@ async def test_open_array(store: Store, zarr_format: ZarrFormat) -> None:
101101
# zipstore is marked as xfail because you cannot open a zipstore in read-only mode if it doesn't exist in the first place.
102102
@pytest.mark.parametrize(
103103
"store",
104-
["local_r", "memory_r", "remote_r", pytest.param("zip_r", marks=pytest.mark.xfail)],
104+
["local", "memory", "remote", "zip"],
105105
indirect=True,
106106
)
107107
def test_open_path_not_found(store: Store, zarr_format: ZarrFormat) -> None:
@@ -111,7 +111,7 @@ def test_open_path_not_found(store: Store, zarr_format: ZarrFormat) -> None:
111111

112112
@pytest.mark.parametrize(
113113
"store",
114-
["local_a", "memory_a", "remote_a", "zip_a"],
114+
["local", "memory", "remote", "zip"],
115115
indirect=True,
116116
)
117117
async def test_open_group(store: Store) -> None:
@@ -144,7 +144,7 @@ async def test_open_group(store: Store) -> None:
144144

145145
@pytest.mark.parametrize(
146146
"store",
147-
["local_a", "memory_a", "remote_a", "zip_a"],
147+
["local", "memory", "remote", "zip"],
148148
indirect=True,
149149
)
150150
async def test_open_array_or_group(zarr_format: ZarrFormat, store: Store) -> None:
@@ -172,7 +172,7 @@ async def test_open_array_or_group(zarr_format: ZarrFormat, store: Store) -> Non
172172

173173
@pytest.mark.parametrize(
174174
"store",
175-
["local_a", "memory_a", "remote_a", "zip_a"],
175+
["local", "memory", "remote", "zip"],
176176
indirect=True,
177177
)
178178
@pytest.mark.parametrize("zarr_format", [None, 2, 3])
@@ -244,7 +244,7 @@ def test_save_errors() -> None:
244244

245245
@pytest.mark.parametrize(
246246
"store",
247-
["local_a", "memory_a", "remote_a", pytest.param("zip_a", marks=pytest.mark.xfail)],
247+
["local", "memory", "remote", pytest.param("zip", marks=pytest.mark.xfail)],
248248
indirect=True,
249249
)
250250
def test_open_with_mode_r(store: Store) -> None:
@@ -265,7 +265,7 @@ def test_open_with_mode_r(store: Store) -> None:
265265

266266
@pytest.mark.parametrize(
267267
"store",
268-
["local_a", "memory_a", "remote_a", pytest.param("zip_a", marks=pytest.mark.xfail)],
268+
["local", "memory", "remote", pytest.param("zip", marks=pytest.mark.xfail)],
269269
indirect=True,
270270
)
271271
def test_open_with_mode_r_plus(store: Store) -> None:
@@ -281,7 +281,7 @@ def test_open_with_mode_r_plus(store: Store) -> None:
281281

282282
@pytest.mark.parametrize(
283283
"store",
284-
["local_a", "memory_a", "remote_a", pytest.param("zip_a", marks=pytest.mark.xfail)],
284+
["local", "memory", "remote", pytest.param("zip", marks=pytest.mark.xfail)],
285285
indirect=True,
286286
)
287287
async def test_open_with_mode_a(store: Store) -> None:
@@ -303,7 +303,7 @@ async def test_open_with_mode_a(store: Store) -> None:
303303

304304
@pytest.mark.parametrize(
305305
"store",
306-
["local_a", "memory_a", "remote_a", pytest.param("zip_a", marks=pytest.mark.xfail)],
306+
["local", "memory", "remote", pytest.param("zip", marks=pytest.mark.xfail)],
307307
indirect=True,
308308
)
309309
def test_open_with_mode_w(store: Store) -> None:
@@ -320,7 +320,7 @@ def test_open_with_mode_w(store: Store) -> None:
320320

321321
@pytest.mark.parametrize(
322322
"store",
323-
["local_a", "memory_a", "remote_a", pytest.param("zip_a", marks=pytest.mark.xfail)],
323+
["local", "memory", "remote", pytest.param("zip", marks=pytest.mark.xfail)],
324324
indirect=True,
325325
)
326326
def test_open_with_mode_w_minus(store: Store) -> None:
@@ -364,7 +364,7 @@ def test_array_order(order: MemoryOrder | None, zarr_format: ZarrFormat) -> None
364364
# assert "LazyLoader: " in repr(loader)
365365

366366

367-
@pytest.mark.parametrize("store", ["local_a", "memory_a", "remote_a", "zip_a"], indirect=True)
367+
@pytest.mark.parametrize("store", ["local", "memory", "remote", "zip"], indirect=True)
368368
def test_load_array(store: Store) -> None:
369369
foo = np.arange(100)
370370
bar = np.arange(100, 0, -1)
@@ -1093,7 +1093,7 @@ def test_open_group_positional_args_deprecated() -> None:
10931093
open_group(store, "w")
10941094

10951095

1096-
@pytest.mark.parametrize("store", ["local_a", "memory_a", "remote_a", "zip_a"], indirect=True)
1096+
@pytest.mark.parametrize("store", ["local", "memory", "remote", "zip"], indirect=True)
10971097
def test_open_falls_back_to_open_group(store: Store) -> None:
10981098
# https://github.com/zarr-developers/zarr-python/issues/2309
10991099
zarr.open_group(store, attributes={"key": "value"})
@@ -1103,7 +1103,7 @@ def test_open_falls_back_to_open_group(store: Store) -> None:
11031103
assert group.attrs == {"key": "value"}
11041104

11051105

1106-
@pytest.mark.parametrize("store", ["local_a", "memory_a", "remote_a", "zip_a"], indirect=True)
1106+
@pytest.mark.parametrize("store", ["local", "memory", "remote", "zip"], indirect=True)
11071107
async def test_open_falls_back_to_open_group_async(store: Store) -> None:
11081108
# https://github.com/zarr-developers/zarr-python/issues/2309
11091109
await zarr.api.asynchronous.open_group(store, attributes={"key": "value"})

tests/test_array.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,19 @@
1010
import zarr.api.asynchronous
1111
from zarr import Array, AsyncArray, Group
1212
from zarr.codecs import BytesCodec, VLenBytesCodec
13-
from zarr.core._info import ArrayInfo
1413
from zarr.core.array import chunks_initialized
1514
from zarr.core.buffer import default_buffer_prototype
1615
from zarr.core.buffer.cpu import NDBuffer
1716
from zarr.core.common import JSON, MemoryOrder, ZarrFormat
1817
from zarr.core.group import AsyncGroup
1918
from zarr.core.indexing import ceildiv
20-
from zarr.core.metadata.v3 import DataType
2119
from zarr.core.sync import sync
2220
from zarr.errors import ContainsArrayError, ContainsGroupError
2321
from zarr.storage import LocalStore, MemoryStore
2422
from zarr.storage.common import StorePath
2523

2624

27-
@pytest.mark.parametrize("store", ["local_a", "memory_a", "zip_a", "remote_a"], indirect=["store"])
25+
@pytest.mark.parametrize("store", ["local", "memory", "zip", "remote"], indirect=["store"])
2826
@pytest.mark.parametrize("zarr_format", [2, 3])
2927
@pytest.mark.parametrize("exists_ok", [True, False])
3028
@pytest.mark.parametrize("extant_node", ["array", "group"])
@@ -75,7 +73,7 @@ def test_array_creation_existing_node(
7573
)
7674

7775

78-
@pytest.mark.parametrize("store", ["local_a", "memory_a", "zip_a", "remote_a"], indirect=["store"])
76+
@pytest.mark.parametrize("store", ["local", "memory", "zip", "remote"], indirect=["store"])
7977
@pytest.mark.parametrize("zarr_format", [2, 3])
8078
async def test_create_creates_parents(
8179
store: LocalStore | MemoryStore, zarr_format: ZarrFormat
@@ -115,7 +113,7 @@ async def test_create_creates_parents(
115113
assert isinstance(g, AsyncGroup)
116114

117115

118-
@pytest.mark.parametrize("store", ["local_a", "memory_a", "zip_a", "remote_a"], indirect=["store"])
116+
@pytest.mark.parametrize("store", ["local", "memory", "zip", "remote"], indirect=["store"])
119117
@pytest.mark.parametrize("zarr_format", [2, 3])
120118
def test_array_name_properties_no_group(
121119
store: LocalStore | MemoryStore, zarr_format: ZarrFormat
@@ -126,7 +124,7 @@ def test_array_name_properties_no_group(
126124
assert arr.basename is None
127125

128126

129-
@pytest.mark.parametrize("store", ["local_a", "memory_a", "zip_a"], indirect=["store"])
127+
@pytest.mark.parametrize("store", ["local", "memory", "zip"], indirect=["store"])
130128
@pytest.mark.parametrize("zarr_format", [2, 3])
131129
def test_array_name_properties_with_group(
132130
store: LocalStore | MemoryStore, zarr_format: ZarrFormat
@@ -145,7 +143,7 @@ def test_array_name_properties_with_group(
145143
assert spam.basename == "spam"
146144

147145

148-
@pytest.mark.parametrize("store", ["memory_a"], indirect=True)
146+
@pytest.mark.parametrize("store", ["memory"], indirect=True)
149147
@pytest.mark.parametrize("specifiy_fill_value", [True, False])
150148
@pytest.mark.parametrize("dtype_str", ["bool", "uint8", "complex64"])
151149
def test_array_v3_fill_value_default(
@@ -175,7 +173,7 @@ def test_array_v3_fill_value_default(
175173
assert arr.fill_value.dtype == arr.dtype
176174

177175

178-
@pytest.mark.parametrize("store", ["memory_a"], indirect=True)
176+
@pytest.mark.parametrize("store", ["memory"], indirect=True)
179177
@pytest.mark.parametrize(
180178
("dtype_str", "fill_value"),
181179
[("bool", True), ("uint8", 99), ("float32", -99.9), ("complex64", 3 + 4j)],
@@ -236,7 +234,7 @@ def test_selection_positional_args_deprecated() -> None:
236234
arr.set_block_selection((0, slice(None)), 1, None)
237235

238236

239-
@pytest.mark.parametrize("store", ["memory_a"], indirect=True)
237+
@pytest.mark.parametrize("store", ["memory"], indirect=True)
240238
async def test_array_v3_nan_fill_value(store: MemoryStore) -> None:
241239
shape = (10,)
242240
arr = Array.create(
@@ -255,7 +253,7 @@ async def test_array_v3_nan_fill_value(store: MemoryStore) -> None:
255253
assert len([a async for a in store.list_prefix("/")]) == 0
256254

257255

258-
@pytest.mark.parametrize("store", ["local_a"], indirect=["store"])
256+
@pytest.mark.parametrize("store", ["local"], indirect=["store"])
259257
@pytest.mark.parametrize("zarr_format", [2, 3])
260258
async def test_serializable_async_array(
261259
store: LocalStore | MemoryStore, zarr_format: ZarrFormat
@@ -273,7 +271,7 @@ async def test_serializable_async_array(
273271
# TODO: uncomment the parts of this test that will be impacted by the config/prototype changes in flight
274272

275273

276-
@pytest.mark.parametrize("store", ["local_a"], indirect=["store"])
274+
@pytest.mark.parametrize("store", ["local"], indirect=["store"])
277275
@pytest.mark.parametrize("zarr_format", [2, 3])
278276
def test_serializable_sync_array(store: LocalStore, zarr_format: ZarrFormat) -> None:
279277
expected = Array.create(
@@ -288,7 +286,7 @@ def test_serializable_sync_array(store: LocalStore, zarr_format: ZarrFormat) ->
288286
np.testing.assert_array_equal(actual[:], expected[:])
289287

290288

291-
@pytest.mark.parametrize("store", ["memory_a"], indirect=True)
289+
@pytest.mark.parametrize("store", ["memory"], indirect=True)
292290
def test_storage_transformers(store: MemoryStore) -> None:
293291
"""
294292
Test that providing an actual storage transformer produces a warning and otherwise passes through
@@ -418,7 +416,7 @@ def test_update_attrs(zarr_format: int) -> None:
418416
assert arr2.attrs["foo"] == "bar"
419417

420418

421-
@pytest.mark.parametrize("store", ["memory_a"], indirect=True)
419+
@pytest.mark.parametrize("store", ["memory"], indirect=True)
422420
@pytest.mark.parametrize("zarr_format", [2, 3])
423421
def test_resize_1d(store: MemoryStore, zarr_format: int) -> None:
424422
z = zarr.create(
@@ -457,7 +455,7 @@ def test_resize_1d(store: MemoryStore, zarr_format: int) -> None:
457455
assert new_shape == z[:].shape
458456

459457

460-
@pytest.mark.parametrize("store", ["memory_a"], indirect=True)
458+
@pytest.mark.parametrize("store", ["memory"], indirect=True)
461459
@pytest.mark.parametrize("zarr_format", [2, 3])
462460
def test_resize_2d(store: MemoryStore, zarr_format: int) -> None:
463461
z = zarr.create(
@@ -519,7 +517,7 @@ def test_resize_2d(store: MemoryStore, zarr_format: int) -> None:
519517
assert new_shape == z[:].shape
520518

521519

522-
@pytest.mark.parametrize("store", ["memory_a"], indirect=True)
520+
@pytest.mark.parametrize("store", ["memory"], indirect=True)
523521
@pytest.mark.parametrize("zarr_format", [2, 3])
524522
def test_append_1d(store: MemoryStore, zarr_format: int) -> None:
525523
a = np.arange(105)
@@ -549,7 +547,7 @@ def test_append_1d(store: MemoryStore, zarr_format: int) -> None:
549547
np.testing.assert_array_equal(f, z[:])
550548

551549

552-
@pytest.mark.parametrize("store", ["memory_a"], indirect=True)
550+
@pytest.mark.parametrize("store", ["memory"], indirect=True)
553551
@pytest.mark.parametrize("zarr_format", [2, 3])
554552
def test_append_2d(store: MemoryStore, zarr_format: int) -> None:
555553
a = np.arange(105 * 105, dtype="i4").reshape((105, 105))
@@ -573,7 +571,7 @@ def test_append_2d(store: MemoryStore, zarr_format: int) -> None:
573571
np.testing.assert_array_equal(e, actual)
574572

575573

576-
@pytest.mark.parametrize("store", ["memory_a"], indirect=True)
574+
@pytest.mark.parametrize("store", ["memory"], indirect=True)
577575
@pytest.mark.parametrize("zarr_format", [2, 3])
578576
def test_append_2d_axis(store: MemoryStore, zarr_format: int) -> None:
579577
a = np.arange(105 * 105, dtype="i4").reshape((105, 105))
@@ -595,7 +593,7 @@ def test_append_2d_axis(store: MemoryStore, zarr_format: int) -> None:
595593
np.testing.assert_array_equal(e, z[:])
596594

597595

598-
@pytest.mark.parametrize("store", ["memory_a"], indirect=True)
596+
@pytest.mark.parametrize("store", ["memory"], indirect=True)
599597
@pytest.mark.parametrize("zarr_format", [2, 3])
600598
def test_append_bad_shape(store: MemoryStore, zarr_format: int) -> None:
601599
a = np.arange(100)
@@ -608,7 +606,7 @@ def test_append_bad_shape(store: MemoryStore, zarr_format: int) -> None:
608606

609607
@pytest.mark.parametrize("order", ["C", "F", None])
610608
@pytest.mark.parametrize("zarr_format", [2, 3])
611-
@pytest.mark.parametrize("store", ["memory_a"], indirect=True)
609+
@pytest.mark.parametrize("store", ["memory"], indirect=True)
612610
def test_array_create_order(
613611
order: MemoryOrder | None, zarr_format: int, store: MemoryStore
614612
) -> None:

0 commit comments

Comments
 (0)