34
34
meta_root ,
35
35
getsize ,
36
36
)
37
+ from zarr ._storage .store import v3_api_available
37
38
from zarr ._storage .v3 import (
38
39
ConsolidatedMetadataStoreV3 ,
39
40
DirectoryStoreV3 ,
44
45
)
45
46
from zarr .tests .util import have_fsspec
46
47
48
+ _VERSIONS = v3_api_available and (2 , 3 ) or (2 ,)
49
+
47
50
48
51
def _init_creation_kwargs (zarr_version ):
49
52
kwargs = {'zarr_version' : zarr_version }
@@ -52,7 +55,7 @@ def _init_creation_kwargs(zarr_version):
52
55
return kwargs
53
56
54
57
55
- @pytest .mark .parametrize ('zarr_version' , [ 2 , 3 ] )
58
+ @pytest .mark .parametrize ('zarr_version' , _VERSIONS )
56
59
def test_open_array (path_type , zarr_version ):
57
60
58
61
store = tempfile .mkdtemp ()
@@ -86,7 +89,7 @@ def test_open_array(path_type, zarr_version):
86
89
open ('doesnotexist' , mode = 'r' )
87
90
88
91
89
- @pytest .mark .parametrize ("zarr_version" , [ 2 , 3 ] )
92
+ @pytest .mark .parametrize ("zarr_version" , _VERSIONS )
90
93
def test_open_group (path_type , zarr_version ):
91
94
92
95
store = tempfile .mkdtemp ()
@@ -116,7 +119,7 @@ def test_open_group(path_type, zarr_version):
116
119
assert g .read_only
117
120
118
121
119
- @pytest .mark .parametrize ("zarr_version" , [ 2 , 3 ] )
122
+ @pytest .mark .parametrize ("zarr_version" , _VERSIONS )
120
123
def test_save_errors (zarr_version ):
121
124
with pytest .raises (ValueError ):
122
125
# no arrays provided
@@ -129,6 +132,7 @@ def test_save_errors(zarr_version):
129
132
save ('data/group.zarr' , zarr_version = zarr_version )
130
133
131
134
135
+ @pytest .mark .skipif (not v3_api_available , reason = "V3 is disabled" )
132
136
def test_zarr_v3_save_multiple_unnamed ():
133
137
x = np .ones (8 )
134
138
y = np .zeros (8 )
@@ -142,6 +146,7 @@ def test_zarr_v3_save_multiple_unnamed():
142
146
assert meta_root + 'dataset/arr_1.array.json' in store
143
147
144
148
149
+ @pytest .mark .skipif (not v3_api_available , reason = "V3 is disabled" )
145
150
def test_zarr_v3_save_errors ():
146
151
x = np .ones (8 )
147
152
with pytest .raises (ValueError ):
@@ -155,7 +160,7 @@ def test_zarr_v3_save_errors():
155
160
save ('data/group.zr3' , x , zarr_version = 3 )
156
161
157
162
158
- @pytest .mark .parametrize ("zarr_version" , [ 2 , 3 ] )
163
+ @pytest .mark .parametrize ("zarr_version" , _VERSIONS )
159
164
def test_lazy_loader (zarr_version ):
160
165
foo = np .arange (100 )
161
166
bar = np .arange (100 , 0 , - 1 )
@@ -173,7 +178,7 @@ def test_lazy_loader(zarr_version):
173
178
assert 'LazyLoader: ' in repr (loader )
174
179
175
180
176
- @pytest .mark .parametrize ("zarr_version" , [ 2 , 3 ] )
181
+ @pytest .mark .parametrize ("zarr_version" , _VERSIONS )
177
182
def test_load_array (zarr_version ):
178
183
foo = np .arange (100 )
179
184
bar = np .arange (100 , 0 , - 1 )
@@ -192,7 +197,7 @@ def test_load_array(zarr_version):
192
197
assert_array_equal (bar , array )
193
198
194
199
195
- @pytest .mark .parametrize ("zarr_version" , [ 2 , 3 ] )
200
+ @pytest .mark .parametrize ("zarr_version" , _VERSIONS )
196
201
def test_tree (zarr_version ):
197
202
kwargs = _init_creation_kwargs (zarr_version )
198
203
g1 = zarr .group (** kwargs )
@@ -205,7 +210,7 @@ def test_tree(zarr_version):
205
210
assert str (zarr .tree (g1 )) == str (g1 .tree ())
206
211
207
212
208
- @pytest .mark .parametrize ('zarr_version' , [ 2 , 3 ] )
213
+ @pytest .mark .parametrize ('zarr_version' , _VERSIONS )
209
214
@pytest .mark .parametrize ('stores_from_path' , [False , True ])
210
215
@pytest .mark .parametrize (
211
216
'with_chunk_store,listable' ,
@@ -531,6 +536,7 @@ def test_if_exists(self):
531
536
copy_store (source , dest , if_exists = 'foobar' )
532
537
533
538
539
+ @pytest .mark .skipif (not v3_api_available , reason = "V3 is disabled" )
534
540
class TestCopyStoreV3 (TestCopyStore ):
535
541
536
542
_version = 3
@@ -666,6 +672,7 @@ def test_copy_all():
666
672
assert destination_group .subgroup .attrs ["info" ] == "sub attrs"
667
673
668
674
675
+ @pytest .mark .skipif (not v3_api_available , reason = "V3 is disabled" )
669
676
def test_copy_all_v3 ():
670
677
"""
671
678
https://github.com/zarr-developers/zarr-python/issues/269
@@ -931,6 +938,7 @@ def test_logging(self, source, dest, tmpdir):
931
938
copy (source ['foo' ], dest , dry_run = True , log = True )
932
939
933
940
941
+ @pytest .mark .skipif (not v3_api_available , reason = "V3 is disabled" )
934
942
class TestCopyV3 (TestCopy ):
935
943
936
944
@pytest .fixture (params = ['zarr' , 'hdf5' ])
0 commit comments