Skip to content

Commit 82fd178

Browse files
committed
assert type in test_load_zip and test_load_local
1 parent c677cd3 commit 82fd178

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

tests/test_api.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -401,36 +401,35 @@ def test_load_array(memory_store: Store) -> None:
401401

402402

403403
@pytest.mark.parametrize("path", ["data", None])
404-
def test_load_zip(tmp_path: pathlib.Path, path: str | None) -> None:
404+
@pytest.mark.parametrize("load_read_only", [True, False, None])
405+
def test_load_zip(tmp_path: pathlib.Path, path: str | None, load_read_only: bool | None) -> None:
405406
file = tmp_path / "test.zip"
406407
data = np.arange(100).reshape(10, 10)
407408

408409
with ZipStore(file, mode="w", read_only=False) as zs:
409410
save(zs, data, path=path)
410-
with ZipStore(file, mode="r", read_only=False) as zs:
411+
with ZipStore(file, mode="r", read_only=load_read_only) as zs:
411412
result = zarr.load(store=zs, path=path)
413+
assert isinstance(result, np.ndarray)
412414
assert np.array_equal(result, data)
413-
with ZipStore(file, mode="r") as zs:
415+
with ZipStore(file, read_only=load_read_only) as zs:
414416
result = zarr.load(store=zs, path=path)
415-
assert_array_equal(result, data)
416-
with ZipStore(file, read_only=True) as zs:
417-
result = zarr.load(store=zs, path=path)
418-
assert_array_equal(result, data)
417+
assert isinstance(result, np.ndarray)
418+
assert np.array_equal(result, data)
419419

420420

421421
@pytest.mark.parametrize("path", ["data", None])
422-
def test_load_local(tmp_path: pathlib.Path, path: str | None) -> None:
422+
@pytest.mark.parametrize("load_read_only", [True, False])
423+
def test_load_local(tmp_path: pathlib.Path, path: str | None, load_read_only: bool) -> None:
423424
file = tmp_path / "test.zip"
424425
data = np.arange(100).reshape(10, 10)
425426

426427
with LocalStore(file, read_only=False) as zs:
427428
save(zs, data, path=path)
428-
with LocalStore(file, read_only=False) as zs:
429+
with LocalStore(file, read_only=load_read_only) as zs:
429430
result = zarr.load(store=zs, path=path)
430-
assert_array_equal(result, data)
431-
with LocalStore(file, read_only=True) as zs:
432-
result = zarr.load(store=zs, path=path)
433-
assert_array_equal(result, data)
431+
assert isinstance(result, np.ndarray)
432+
assert np.array_equal(result, data)
434433

435434

436435
def test_tree() -> None:

0 commit comments

Comments
 (0)