@@ -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+
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+ )
178195
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
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
@@ -245,14 +282,26 @@ def test_list_cache_reuse(server):
245282
246283 # Verify that yet another new instance, with caching enabled,
247284 # 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+ )
249291 assert len (h .dircache ) == 1
250292
251293 # However, yet another instance with a different expiry time will also not have
252294 # 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+ )
254301 assert len (h .dircache ) == 0
255302
303+ h .dircache .clear () # clean up
304+
256305
257306def test_ls_raises_filenotfound (server ):
258307 h = fsspec .filesystem ("http" )
@@ -267,8 +316,14 @@ def test_list_cache_with_max_paths(server):
267316 assert out == [server + "/index/realfile" ]
268317
269318
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+ )
272327 out = h .glob (server + "/index/*" )
273328 assert out == [server + "/index/realfile" ]
274329
0 commit comments