File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # tests/test_store/test_protocols.py
2+ """Runtime and static conformance tests for zarr.storage._protocols.SupportsGetRanges."""
3+
4+ from __future__ import annotations
5+
6+ import pytest
7+
8+ from zarr .storage ._protocols import SupportsGetRanges
9+
10+
11+ def test_fsspec_store_satisfies_supports_get_ranges () -> None :
12+ pytest .importorskip ("fsspec" )
13+ from fsspec .implementations .memory import MemoryFileSystem
14+
15+ from zarr .storage import FsspecStore
16+ from zarr .storage ._fsspec import _make_async
17+
18+ fs = MemoryFileSystem ()
19+ fs .store .clear ()
20+ store = FsspecStore (fs = _make_async (fs ), path = "/x" )
21+ assert isinstance (store , SupportsGetRanges )
22+
23+
24+ def test_memory_store_does_not_satisfy_supports_get_ranges () -> None :
25+ """Sanity check: stores that don't implement get_ranges shouldn't satisfy the protocol."""
26+ from zarr .storage import MemoryStore
27+
28+ store = MemoryStore ()
29+ assert not isinstance (store , SupportsGetRanges )
30+
31+
32+ def test_type_assignment_at_module_level () -> None :
33+ """Smoke-test the module-level `_: type[SupportsGetRanges] = FsspecStore`.
34+
35+ If this runs without error the module imported cleanly; the static check is in mypy.
36+ """
37+ pytest .importorskip ("fsspec" )
38+ from zarr .storage import _fsspec # noqa: F401
You can’t perform that action at this time.
0 commit comments