@@ -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
+
178
186
179
- def test_list_cache_with_expiry_time_cached (server ):
180
- h = fsspec .filesystem ("http" , use_listings_cache = True , listings_expiry_time = 30 )
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
+ )
195
+
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
@@ -253,6 +290,8 @@ def test_list_cache_reuse(server):
253
290
h = fsspec .filesystem ("http" , use_listings_cache = True , listings_expiry_time = 666 )
254
291
assert len (h .dircache ) == 0
255
292
293
+ h .dircache .clear () # clean up
294
+
256
295
257
296
def test_ls_raises_filenotfound (server ):
258
297
h = fsspec .filesystem ("http" )
@@ -267,8 +306,14 @@ def test_list_cache_with_max_paths(server):
267
306
assert out == [server + "/index/realfile" ]
268
307
269
308
270
- def test_list_cache_with_skip_instance_cache (server ):
271
- h = fsspec .filesystem ("http" , use_listings_cache = True , skip_instance_cache = True )
309
+ @pytest .mark .parametrize ("listings_cache_type" , ["memdircache" , "filedircache" ])
310
+ def test_list_cache_with_skip_instance_cache (server , listings_cache_type ):
311
+ h = fsspec .filesystem (
312
+ "http" ,
313
+ use_listings_cache = True ,
314
+ skip_instance_cache = True ,
315
+ listings_cache_type = listings_cache_type ,
316
+ )
272
317
out = h .glob (server + "/index/*" )
273
318
assert out == [server + "/index/realfile" ]
274
319
0 commit comments