@@ -900,13 +900,20 @@ def mock_walker_no_slash(_path):
900
900
@pytest .mark .skipif (have_fsspec is False , reason = "needs fsspec" )
901
901
class TestFSStore (StoreTests ):
902
902
903
- def create_store (self , normalize_keys = False , dimension_separator = "." ):
904
- path = tempfile .mkdtemp ()
905
- atexit .register (atexit_rmtree , path )
903
+ def create_store (self , normalize_keys = False ,
904
+ dimension_separator = "." ,
905
+ path = None ,
906
+ ** kwargs ):
907
+
908
+ if path is None :
909
+ path = tempfile .mkdtemp ()
910
+ atexit .register (atexit_rmtree , path )
911
+
906
912
store = FSStore (
907
913
path ,
908
914
normalize_keys = normalize_keys ,
909
- dimension_separator = dimension_separator )
915
+ dimension_separator = dimension_separator ,
916
+ ** kwargs )
910
917
return store
911
918
912
919
def test_init_array (self ):
@@ -937,8 +944,9 @@ def test_dimension_separator(self):
937
944
def test_complex (self ):
938
945
path1 = tempfile .mkdtemp ()
939
946
path2 = tempfile .mkdtemp ()
940
- store = FSStore ("simplecache::file://" + path1 ,
941
- simplecache = {"same_names" : True , "cache_storage" : path2 })
947
+ store = self .create_store (path = "simplecache::file://" + path1 ,
948
+ simplecache = {"same_names" : True ,
949
+ "cache_storage" : path2 })
942
950
assert not store
943
951
assert not os .listdir (path1 )
944
952
assert not os .listdir (path2 )
@@ -979,10 +987,10 @@ def test_create(self):
979
987
def test_read_only (self ):
980
988
path = tempfile .mkdtemp ()
981
989
atexit .register (atexit_rmtree , path )
982
- store = FSStore ( path )
990
+ store = self . create_store ( path = path )
983
991
store ['foo' ] = b"bar"
984
992
985
- store = FSStore ( path , mode = 'r' )
993
+ store = self . create_store ( path = path , mode = 'r' )
986
994
987
995
with pytest .raises (PermissionError ):
988
996
store ['foo' ] = b"hex"
@@ -1000,11 +1008,11 @@ def test_read_only(self):
1000
1008
1001
1009
filepath = os .path .join (path , "foo" )
1002
1010
with pytest .raises (ValueError ):
1003
- FSStore ( filepath , mode = 'r' )
1011
+ self . create_store ( path = filepath , mode = 'r' )
1004
1012
1005
1013
def test_eq (self ):
1006
- store1 = FSStore ( "anypath" )
1007
- store2 = FSStore ( "anypath" )
1014
+ store1 = self . create_store ( path = "anypath" )
1015
+ store2 = self . create_store ( path = "anypath" )
1008
1016
assert store1 == store2
1009
1017
1010
1018
@pytest .mark .usefixtures ("s3" )
@@ -1300,10 +1308,13 @@ def test_filters(self):
1300
1308
1301
1309
@pytest .mark .skipif (have_fsspec is False , reason = "needs fsspec" )
1302
1310
class TestN5FSStore (TestFSStore ):
1303
- def create_store (self , normalize_keys = False ):
1304
- path = tempfile .mkdtemp ()
1305
- atexit .register (atexit_rmtree , path )
1306
- store = N5FSStore (path , normalize_keys = normalize_keys )
1311
+ def create_store (self , normalize_keys = False , path = None , ** kwargs ):
1312
+
1313
+ if path is None :
1314
+ path = tempfile .mkdtemp ()
1315
+ atexit .register (atexit_rmtree , path )
1316
+
1317
+ store = N5FSStore (path , normalize_keys = normalize_keys , ** kwargs )
1307
1318
return store
1308
1319
1309
1320
def test_equal (self ):
@@ -1375,8 +1386,9 @@ def test_init_group_overwrite_chunk_store(self):
1375
1386
self ._test_init_group_overwrite_chunk_store ('C' )
1376
1387
1377
1388
def test_dimension_separator (self ):
1378
- with pytest .raises (TypeError ):
1379
- self .create_store (key_separator = '.' )
1389
+
1390
+ with pytest .warns (UserWarning , match = 'dimension_separator' ):
1391
+ self .create_store (dimension_separator = '/' )
1380
1392
1381
1393
1382
1394
@pytest .mark .skipif (have_fsspec is False , reason = "needs fsspec" )
0 commit comments