55import pytest
66from numpy .testing import assert_array_equal
77
8+ from tests .conftest import as_immutable
89import zarr
910import zarr .api .asynchronous
1011import zarr .core .group
@@ -70,29 +71,13 @@ async def test_open_array(store: Store, zarr_format: ZarrFormat) -> None:
7071 assert isinstance (z , Array )
7172 assert z .shape == (100 ,)
7273
73- store_w : Store
7474
75- if isinstance (store , ZipStore ):
76- store .close ()
77- store_w = await ZipStore .open (store .path , mode = "w" )
78- else :
79- # open array, overwrite
80- store_w = store .with_mode ("w" )
81-
82- z = open (store = store_w , shape = 200 , zarr_format = zarr_format )
75+ z = open (store = store , shape = 200 , zarr_format = zarr_format , mode = 'w' )
8376 assert isinstance (z , Array )
8477 assert z .shape == (200 ,)
8578
86- store_r : Store
87-
88- if isinstance (store , ZipStore ):
89- store_w .close ()
90- store_r = await ZipStore .open (store .path , mode = "r" )
91- else :
92- # open array, read-only
93- store_r = store .with_mode ("r" )
94-
95- z = open (store = store_r , zarr_format = zarr_format )
79+ store_r = as_immutable (store )
80+ z = open (store = store_r , zarr_format = zarr_format , mode = 'r' )
9681 assert isinstance (z , Array )
9782 assert z .shape == (200 ,)
9883 assert z .read_only
@@ -125,15 +110,7 @@ async def test_open_group(store: Store) -> None:
125110 # g = open_group(store=store)
126111 # assert isinstance(g, Group)
127112 # assert "foo" not in g
128- store_r : Store
129-
130- # open group, read-only
131- if isinstance (store , ZipStore ):
132- store .close ()
133- store_r = await ZipStore .open (store .path , mode = "r" )
134- else :
135- # open array, read-only
136- store_r = store .with_mode ("r" )
113+ store_r = as_immutable (store )
137114
138115 g = open_group (store = store_r )
139116 assert isinstance (g , Group )
@@ -1059,13 +1036,14 @@ def test_tree() -> None:
10591036# copy(source["foo"], dest, dry_run=True, log=True)
10601037
10611038
1062- def test_open_positional_args_deprecated () -> None :
1063- store = MemoryStore ()
1039+ @ pytest . mark . parametrize ( "store" , [ "memory" ], indirect = True )
1040+ def test_open_positional_args_deprecated ( store : MemoryStore ) -> None :
10641041 with pytest .warns (FutureWarning , match = "pass" ):
10651042 open (store , "w" , shape = (1 ,))
10661043
10671044
1068- def test_save_array_positional_args_deprecated () -> None :
1045+ @pytest .mark .parametrize ("store" , ["memory" ], indirect = True )
1046+ def test_save_array_positional_args_deprecated (store : MemoryStore ) -> None :
10691047 store = MemoryStore ()
10701048 with warnings .catch_warnings ():
10711049 warnings .filterwarnings (
@@ -1081,14 +1059,14 @@ def test_save_array_positional_args_deprecated() -> None:
10811059 )
10821060
10831061
1084- def test_group_positional_args_deprecated () -> None :
1085- store = MemoryStore ()
1062+ @ pytest . mark . parametrize ( "store" , [ "memory" ], indirect = True )
1063+ def test_group_positional_args_deprecated ( store : MemoryStore ) -> None :
10861064 with pytest .warns (FutureWarning , match = "pass" ):
10871065 group (store , True )
10881066
10891067
1090- def test_open_group_positional_args_deprecated () -> None :
1091- store = MemoryStore ()
1068+ @ pytest . mark . parametrize ( "store" , [ "memory" ], indirect = True )
1069+ def test_open_group_positional_args_deprecated ( store : MemoryStore ) -> None :
10921070 with pytest .warns (FutureWarning , match = "pass" ):
10931071 open_group (store , "w" )
10941072
0 commit comments