@@ -1098,6 +1098,12 @@ def mock_walker_no_slash(_path):
1098
1098
1099
1099
@pytest .mark .skipif (have_fsspec is False , reason = "needs fsspec" )
1100
1100
class TestFSStore (StoreTests ):
1101
+ @pytest .fixture
1102
+ def memory_store (self ):
1103
+ store = FSStore ("memory://" )
1104
+ yield store
1105
+ store .fs .store .clear ()
1106
+
1101
1107
def create_store (self , normalize_keys = False , dimension_separator = "." , path = None , ** kwargs ):
1102
1108
if path is None :
1103
1109
path = tempfile .mkdtemp ()
@@ -1337,6 +1343,25 @@ def test_s3_complex(self):
1337
1343
)
1338
1344
assert (a [:] == - np .ones ((8 , 8 , 8 ))).all ()
1339
1345
1346
+ def test_exceptions (self , memory_store ):
1347
+ fs = memory_store .fs
1348
+ group = zarr .open (memory_store , mode = "w" )
1349
+ x = group .create_dataset ("x" , data = [1 , 2 , 3 ])
1350
+ y = group .create_dataset ("y" , data = 1 )
1351
+ fs .store ["/x/0" ] = None
1352
+ fs .store ["/y/0" ] = None
1353
+ # no exception from FSStore.getitems getting KeyError
1354
+ assert group .store .getitems (["foo" ], contexts = {}) == {}
1355
+ # exception from FSStore.getitems getting AttributeError
1356
+ with pytest .raises (Exception ):
1357
+ group .store .getitems (["x/0" ], contexts = {})
1358
+ # exception from FSStore.getitems getting AttributeError
1359
+ with pytest .raises (Exception ):
1360
+ x [...]
1361
+ # exception from FSStore.__getitem__ getting AttributeError
1362
+ with pytest .raises (Exception ):
1363
+ y [...]
1364
+
1340
1365
1341
1366
@pytest .mark .skipif (have_fsspec is False , reason = "needs fsspec" )
1342
1367
class TestFSStoreWithKeySeparator (StoreTests ):
0 commit comments