@@ -170,14 +170,30 @@ def test_list_invalid_args(server):
170
170
h .glob (server + "/index/*" )
171
171
172
172
173
- def test_list_cache (server ):
174
- h = fsspec .filesystem ("http" , use_listings_cache = True )
173
+ @pytest .mark .parametrize ("listings_cache_type" , ["memdircache" , "filedircache" ])
174
+ def test_list_cache (server , listings_cache_type ):
175
+ h = fsspec .filesystem (
176
+ "http" , use_listings_cache = True , listings_cache_type = listings_cache_type
177
+ )
178
+
179
+ h .dircache .clear () # Needed for filedircache
180
+
175
181
out = h .glob (server + "/index/*" )
176
182
assert out == [server + "/index/realfile" ]
177
183
184
+ h .dircache .clear () # clean up
185
+
186
+
187
+ @pytest .mark .parametrize ("listings_cache_type" , ["memdircache" , "filedircache" ])
188
+ def test_list_cache_with_expiry_time_cached (server , listings_cache_type ):
189
+ h = fsspec .filesystem (
190
+ "http" ,
191
+ use_listings_cache = True ,
192
+ listings_expiry_time = 30 ,
193
+ listings_cache_type = listings_cache_type ,
194
+ )
178
195
179
- def test_list_cache_with_expiry_time_cached (server ):
180
- h = fsspec .filesystem ("http" , use_listings_cache = True , listings_expiry_time = 30 )
196
+ h .dircache .clear () # Needed for filedircache
181
197
182
198
# First, the directory cache is not initialized.
183
199
assert not h .dircache
@@ -193,9 +209,19 @@ def test_list_cache_with_expiry_time_cached(server):
193
209
out = h .glob (server + "/index/*" )
194
210
assert out == [server + "/index/realfile" ]
195
211
212
+ h .dircache .clear () # clean up
213
+
214
+
215
+ @pytest .mark .parametrize ("listings_cache_type" , ["memdircache" , "filedircache" ])
216
+ def test_list_cache_with_expiry_time_purged (server , listings_cache_type ):
217
+ h = fsspec .filesystem (
218
+ "http" ,
219
+ use_listings_cache = True ,
220
+ listings_expiry_time = 0.3 ,
221
+ listings_cache_type = listings_cache_type ,
222
+ )
196
223
197
- def test_list_cache_with_expiry_time_purged (server ):
198
- h = fsspec .filesystem ("http" , use_listings_cache = True , listings_expiry_time = 0.3 )
224
+ h .dircache .clear () # Needed for filedircache
199
225
200
226
# First, the directory cache is not initialized.
201
227
assert not h .dircache
@@ -224,9 +250,20 @@ def test_list_cache_with_expiry_time_purged(server):
224
250
cached_items = h .dircache .get (server + "/index/" )
225
251
assert len (cached_items ) == 1
226
252
253
+ h .dircache .clear () # clean up
227
254
228
- def test_list_cache_reuse (server ):
229
- h = fsspec .filesystem ("http" , use_listings_cache = True , listings_expiry_time = 5 )
255
+
256
+ @pytest .mark .parametrize ("listings_cache_type" , ["memdircache" , "filedircache" ])
257
+ def test_list_cache_reuse (server , listings_cache_type ):
258
+ h = fsspec .filesystem (
259
+ "http" ,
260
+ use_listings_cache = True ,
261
+ listings_expiry_time = 5 ,
262
+ listings_cache_type = listings_cache_type ,
263
+ )
264
+
265
+ # Needed for filedircache
266
+ h .dircache .clear ()
230
267
231
268
# First, the directory cache is not initialized.
232
269
assert not h .dircache
@@ -245,14 +282,26 @@ def test_list_cache_reuse(server):
245
282
246
283
# Verify that yet another new instance, with caching enabled,
247
284
# will see the same cache content again.
248
- h = fsspec .filesystem ("http" , use_listings_cache = True , listings_expiry_time = 5 )
285
+ h = fsspec .filesystem (
286
+ "http" ,
287
+ use_listings_cache = True ,
288
+ listings_expiry_time = 5 ,
289
+ listings_cache_type = listings_cache_type ,
290
+ )
249
291
assert len (h .dircache ) == 1
250
292
251
293
# However, yet another instance with a different expiry time will also not have
252
294
# any valid cache content.
253
- h = fsspec .filesystem ("http" , use_listings_cache = True , listings_expiry_time = 666 )
295
+ h = fsspec .filesystem (
296
+ "http" ,
297
+ use_listings_cache = True ,
298
+ listings_expiry_time = 666 ,
299
+ listings_cache_type = listings_cache_type ,
300
+ )
254
301
assert len (h .dircache ) == 0
255
302
303
+ h .dircache .clear () # clean up
304
+
256
305
257
306
def test_ls_raises_filenotfound (server ):
258
307
h = fsspec .filesystem ("http" )
@@ -267,8 +316,14 @@ def test_list_cache_with_max_paths(server):
267
316
assert out == [server + "/index/realfile" ]
268
317
269
318
270
- def test_list_cache_with_skip_instance_cache (server ):
271
- h = fsspec .filesystem ("http" , use_listings_cache = True , skip_instance_cache = True )
319
+ @pytest .mark .parametrize ("listings_cache_type" , ["memdircache" , "filedircache" ])
320
+ def test_list_cache_with_skip_instance_cache (server , listings_cache_type ):
321
+ h = fsspec .filesystem (
322
+ "http" ,
323
+ use_listings_cache = True ,
324
+ skip_instance_cache = True ,
325
+ listings_cache_type = listings_cache_type ,
326
+ )
272
327
out = h .glob (server + "/index/*" )
273
328
assert out == [server + "/index/realfile" ]
274
329
0 commit comments