Skip to content

Commit c5b3588

Browse files
committed
add old open_with_mode_r test
1 parent f946499 commit c5b3588

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

tests/test_api.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pathlib
12
import warnings
23
from typing import Literal
34

@@ -228,7 +229,7 @@ def test_save_errors() -> None:
228229
["local", "memory", "remote", pytest.param("zip", marks=pytest.mark.xfail)],
229230
indirect=True,
230231
)
231-
def test_open_with_mode_r(store: Store) -> None:
232+
def test_open_store_with_mode_r(store: Store) -> None:
232233
# 'r' means read only (must exist)
233234
with pytest.raises(FileNotFoundError):
234235
zarr.open(store=store, mode="r")
@@ -244,6 +245,20 @@ def test_open_with_mode_r(store: Store) -> None:
244245
z2[:] = 3
245246

246247

248+
def test_open_path_with_mode_r(tmp_path: pathlib.Path) -> None:
249+
# 'r' means read only (must exist)
250+
with pytest.raises(FileNotFoundError):
251+
zarr.open(store=tmp_path, mode="r")
252+
z1 = zarr.ones(store=tmp_path, shape=(3, 3))
253+
assert z1.fill_value == 1
254+
z2 = zarr.open(store=tmp_path, mode="r")
255+
assert isinstance(z2, Array)
256+
assert z2.fill_value == 1
257+
assert (z2[:] == 1).all()
258+
with pytest.raises(ValueError):
259+
z2[:] = 3
260+
261+
247262
@pytest.mark.parametrize(
248263
"store",
249264
["local", "memory", "remote", "zip"],

0 commit comments

Comments
 (0)