Skip to content

Commit e586001

Browse files
committed
Move test to fsspec store
1 parent ed11018 commit e586001

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

tests/test_api.py

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ def test_create(memory_store: Store) -> None:
5151

5252
# create array with float shape
5353
with pytest.raises(TypeError):
54-
z = create(shape=(400.5, 100), store=store, overwrite=True) # type: ignore [arg-type]
54+
z = create(shape=(400.5, 100), store=store, overwrite=True)
5555

5656
# create array with float chunk shape
5757
with pytest.raises(TypeError):
58-
z = create(shape=(400, 100), chunks=(16, 16.5), store=store, overwrite=True) # type: ignore [arg-type]
58+
z = create(shape=(400, 100), chunks=(16, 16.5), store=store, overwrite=True)
5959

6060

6161
# TODO: parametrize over everything this function takes
@@ -200,7 +200,7 @@ def test_save(store: Store, n_args: int, n_kwargs: int) -> None:
200200
assert isinstance(array, Array)
201201
assert_array_equal(array[:], data)
202202
else:
203-
save(store, *args, **kwargs) # type: ignore[arg-type]
203+
save(store, *args, **kwargs)
204204
group = open(store)
205205
assert isinstance(group, Group)
206206
for array in group.array_values():
@@ -288,23 +288,6 @@ def test_open_with_mode_w_minus(tmp_path: pathlib.Path) -> None:
288288
zarr.open(store=tmp_path, mode="w-")
289289

290290

291-
@pytest.mark.xfail(
292-
reason="Automatic sync -> async filesystems not implemented yet for FSMap objects."
293-
)
294-
def test_open_fsmap_file(tmp_path: pathlib.Path) -> None:
295-
fsspec = pytest.importorskip("fsspec")
296-
fs = fsspec.filesystem("file")
297-
mapper = fs.get_mapper(tmp_path)
298-
arr = zarr.open(store=mapper, mode="w", shape=(3, 3))
299-
assert isinstance(arr, Array)
300-
301-
arr[...] = 3
302-
z2 = zarr.open(store=mapper, mode="w", shape=(3, 3))
303-
assert isinstance(z2, Array)
304-
assert not (z2[:] == 3).all()
305-
z2[:] = 3
306-
307-
308291
@pytest.mark.parametrize("zarr_format", [2, 3])
309292
def test_array_order(zarr_format: ZarrFormat) -> None:
310293
arr = zarr.ones(shape=(2, 2), order=None, zarr_format=zarr_format)
@@ -1115,13 +1098,13 @@ async def test_metadata_validation_error() -> None:
11151098
MetadataValidationError,
11161099
match="Invalid value for 'zarr_format'. Expected '2, 3, or None'. Got '3.0'.",
11171100
):
1118-
await zarr.api.asynchronous.open_group(zarr_format="3.0") # type: ignore[arg-type]
1101+
await zarr.api.asynchronous.open_group(zarr_format="3.0")
11191102

11201103
with pytest.raises(
11211104
MetadataValidationError,
11221105
match="Invalid value for 'zarr_format'. Expected '2, 3, or None'. Got '3.0'.",
11231106
):
1124-
await zarr.api.asynchronous.open_array(shape=(1,), zarr_format="3.0") # type: ignore[arg-type]
1107+
await zarr.api.asynchronous.open_array(shape=(1,), zarr_format="3.0")
11251108

11261109

11271110
@pytest.mark.parametrize(

tests/test_store/test_fsspec.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from zarr.testing.store import StoreTests
1818

1919
if TYPE_CHECKING:
20+
import pathlib
2021
from collections.abc import Generator
2122

2223
import botocore.client
@@ -106,8 +107,23 @@ async def test_basic() -> None:
106107
assert out[0].to_bytes() == data[1:]
107108

108109

110+
@pytest.mark.xfail(reason="See https://github.com/zarr-developers/zarr-python/issues/2808")
111+
def test_open_fsmap_file(tmp_path: pathlib.Path) -> None:
112+
fsspec = pytest.importorskip("fsspec")
113+
fs = fsspec.filesystem("file")
114+
mapper = fs.get_mapper(tmp_path)
115+
arr = zarr.open(store=mapper, mode="w", shape=(3, 3))
116+
assert isinstance(arr, Array)
117+
# Set values
118+
arr[:] = 1
119+
# Read set values
120+
arr = zarr.open(store=mapper, mode="r", shape=(3, 3))
121+
assert isinstance(arr, Array)
122+
np.testing.assert_array_equal(np.ones((3, 3)), arr[:])
123+
124+
109125
@pytest.mark.parametrize("asynchronous", [True, False])
110-
def test_open_s3map(asynchronous: bool) -> None:
126+
def test_open_fsmap_s3(asynchronous: bool) -> None:
111127
s3_filesystem = s3fs.S3FileSystem(
112128
asynchronous=asynchronous, endpoint_url=endpoint_url, anon=False
113129
)

0 commit comments

Comments
 (0)