Skip to content

Commit 58aecc7

Browse files
author
Martin Durant
committed
Skip if no fsspec
1 parent 942bcfb commit 58aecc7

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

zarr/hierarchy.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,7 @@ def group(store=None, overwrite=False, chunk_store=None,
10961096

10971097

10981098
def open_group(store=None, mode='a', cache_attrs=True, synchronizer=None, path=None,
1099-
chunk_store=None):
1099+
chunk_store=None, storage_options=None):
11001100
"""Open a group using file-mode-like semantics.
11011101
11021102
Parameters
@@ -1140,9 +1140,9 @@ def open_group(store=None, mode='a', cache_attrs=True, synchronizer=None, path=N
11401140
"""
11411141

11421142
# handle polymorphic store arg
1143-
store = _normalize_store_arg(store)
1143+
store = _normalize_store_arg(store, storage_options=storage_options)
11441144
if chunk_store is not None:
1145-
chunk_store = _normalize_store_arg(chunk_store)
1145+
chunk_store = _normalize_store_arg(chunk_store, storage_options=storage_options)
11461146
path = normalize_storage_path(path)
11471147

11481148
# ensure store is initialized

zarr/storage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,7 @@ def listdir(self, path=None):
10451045
dir_path = self.dir_path(path)
10461046
try:
10471047
out = sorted(p.rstrip('/').rsplit('/', 1)[-1]
1048-
for p in self.fs.ls(dir_path, detail=False))
1048+
for p in self.fs.ls(dir_path, detail=False))
10491049
return out
10501050
except IOError:
10511051
return []

zarr/tests/test_storage.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
attrs_key, default_compressor, getsize,
3131
group_meta_key, init_array, init_group, migrate_1to2)
3232
from zarr.storage import FSStore
33-
from zarr.tests.util import CountingDict, skip_test_env_var
33+
from zarr.tests.util import CountingDict, have_fsspec, skip_test_env_var
3434

3535

3636
@contextmanager
@@ -828,6 +828,7 @@ def test_normalize_keys(self):
828828
assert 'foo' in store
829829

830830

831+
@pytest.mark.skipif(have_fsspec is False, reason="needs fsspec")
831832
class TestFSStore(StoreTests, unittest.TestCase):
832833

833834
def create_store(self, normalize_keys=False):
@@ -857,8 +858,7 @@ class TestNestedDirectoryStore(TestDirectoryStore, unittest.TestCase):
857858
def create_store(self, normalize_keys=False):
858859
path = tempfile.mkdtemp()
859860
atexit.register(atexit_rmtree, path)
860-
store = NestedDirectoryStore(path, normalize_keys=normalize_keys,
861-
key_separator='/', auto_mkdir=True)
861+
store = NestedDirectoryStore(path, normalize_keys=normalize_keys)
862862
return store
863863

864864
def test_chunk_nesting(self):
@@ -987,6 +987,7 @@ def test_filters(self):
987987
init_array(store, shape=1000, chunks=100, filters=filters)
988988

989989

990+
@pytest.mark.skipif(have_fsspec is False, reason="needs fsspec")
990991
class TestNestedFSStore(TestNestedDirectoryStore):
991992

992993
def create_store(self, normalize_keys=False):

zarr/tests/util.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,10 @@ def skip_test_env_var(name):
4646
"""
4747
value = os.environ.get(name, '0')
4848
return pytest.mark.skipif(value == '0', reason='Tests not enabled via environment variable')
49+
50+
51+
try:
52+
import fsspec # noqa: F401
53+
have_fsspec = True
54+
except ImportError:
55+
have_fsspec = False

0 commit comments

Comments
 (0)