@@ -213,7 +213,8 @@ def test_idempotent():
213
213
assert fs3 .storage == fs .storage
214
214
215
215
216
- def test_blockcache_workflow (ftp_writable , tmp_path ):
216
+ @pytest .mark .parametrize ("force_save_pickle" , [True , False ])
217
+ def test_blockcache_workflow (ftp_writable , tmp_path , force_save_pickle ):
217
218
host , port , user , pw = ftp_writable
218
219
fs = FTPFileSystem (host , port , user , pw )
219
220
with fs .open ("/out" , "wb" ) as f :
@@ -233,6 +234,7 @@ def test_blockcache_workflow(ftp_writable, tmp_path):
233
234
234
235
# Open the blockcache and read a little bit of the data
235
236
fs = fsspec .filesystem ("blockcache" , ** fs_kwargs )
237
+ fs ._metadata ._force_save_pickle = force_save_pickle
236
238
with fs .open ("/out" , "rb" , block_size = 5 ) as f :
237
239
assert f .read (5 ) == b"test\n "
238
240
@@ -241,13 +243,18 @@ def test_blockcache_workflow(ftp_writable, tmp_path):
241
243
del fs
242
244
243
245
# Check that cache file only has the first two blocks
244
- with open (tmp_path / "cache" , "rb" ) as f :
245
- cache = pickle .load (f )
246
- assert "/out" in cache
247
- assert cache ["/out" ]["blocks" ] == [0 , 1 ]
246
+ if force_save_pickle :
247
+ with open (tmp_path / "cache" , "rb" ) as f :
248
+ cache = pickle .load (f )
249
+ else :
250
+ with open (tmp_path / "cache" , "r" ) as f :
251
+ cache = json .load (f )
252
+ assert "/out" in cache
253
+ assert cache ["/out" ]["blocks" ] == [0 , 1 ]
248
254
249
255
# Reopen the same cache and read some more...
250
256
fs = fsspec .filesystem ("blockcache" , ** fs_kwargs )
257
+ fs ._metadata ._force_save_pickle = force_save_pickle
251
258
with fs .open ("/out" , block_size = 5 ) as f :
252
259
assert f .read (5 ) == b"test\n "
253
260
f .seek (30 )
0 commit comments