@@ -1098,6 +1098,12 @@ def mock_walker_no_slash(_path):
10981098
10991099@pytest .mark .skipif (have_fsspec is False , reason = "needs fsspec" )
11001100class TestFSStore (StoreTests ):
1101+ @pytest .fixture
1102+ def memory_store (self ):
1103+ store = FSStore ("memory://" )
1104+ yield store
1105+ store .fs .store .clear ()
1106+
11011107 def create_store (self , normalize_keys = False , dimension_separator = "." , path = None , ** kwargs ):
11021108 if path is None :
11031109 path = tempfile .mkdtemp ()
@@ -1337,6 +1343,25 @@ def test_s3_complex(self):
13371343 )
13381344 assert (a [:] == - np .ones ((8 , 8 , 8 ))).all ()
13391345
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+
13401365
13411366@pytest .mark .skipif (have_fsspec is False , reason = "needs fsspec" )
13421367class TestFSStoreWithKeySeparator (StoreTests ):
0 commit comments