@@ -170,14 +170,30 @@ def test_list_invalid_args(server):
170170 h .glob (server + "/index/*" )
171171
172172
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+
175181 out = h .glob (server + "/index/*" )
176182 assert out == [server + "/index/realfile" ]
177183
184+ h .dircache .clear () # clean up
185+
178186
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
181197
182198 # First, the directory cache is not initialized.
183199 assert not h .dircache
@@ -193,9 +209,19 @@ def test_list_cache_with_expiry_time_cached(server):
193209 out = h .glob (server + "/index/*" )
194210 assert out == [server + "/index/realfile" ]
195211
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+ )
196223
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
199225
200226 # First, the directory cache is not initialized.
201227 assert not h .dircache
@@ -224,9 +250,20 @@ def test_list_cache_with_expiry_time_purged(server):
224250 cached_items = h .dircache .get (server + "/index/" )
225251 assert len (cached_items ) == 1
226252
253+ h .dircache .clear () # clean up
227254
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 ()
230267
231268 # First, the directory cache is not initialized.
232269 assert not h .dircache
@@ -253,6 +290,8 @@ def test_list_cache_reuse(server):
253290 h = fsspec .filesystem ("http" , use_listings_cache = True , listings_expiry_time = 666 )
254291 assert len (h .dircache ) == 0
255292
293+ h .dircache .clear () # clean up
294+
256295
257296def test_ls_raises_filenotfound (server ):
258297 h = fsspec .filesystem ("http" )
@@ -267,8 +306,14 @@ def test_list_cache_with_max_paths(server):
267306 assert out == [server + "/index/realfile" ]
268307
269308
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+ )
272317 out = h .glob (server + "/index/*" )
273318 assert out == [server + "/index/realfile" ]
274319
0 commit comments