@@ -26,14 +26,30 @@ def test_list_invalid_args(server):
2626 h .glob (server + "/index/*" )
2727
2828
29- def test_list_cache (server ):
30- h = fsspec .filesystem ("http" , use_listings_cache = True )
29+ @pytest .mark .parametrize ("listings_cache_type" , ["memdircache" , "filedircache" ])
30+ def test_list_cache (server , listings_cache_type ):
31+ h = fsspec .filesystem (
32+ "http" , use_listings_cache = True , listings_cache_type = listings_cache_type
33+ )
34+
35+ h .dircache .clear () # Needed for filedircache
36+
3137 out = h .glob (server + "/index/*" )
3238 assert out == [server + "/index/realfile" ]
3339
40+ h .dircache .clear () # clean up
41+
42+
43+ @pytest .mark .parametrize ("listings_cache_type" , ["memdircache" , "filedircache" ])
44+ def test_list_cache_with_expiry_time_cached (server , listings_cache_type ):
45+ h = fsspec .filesystem (
46+ "http" ,
47+ use_listings_cache = True ,
48+ listings_expiry_time = 30 ,
49+ listings_cache_type = listings_cache_type ,
50+ )
3451
35- def test_list_cache_with_expiry_time_cached (server ):
36- h = fsspec .filesystem ("http" , use_listings_cache = True , listings_expiry_time = 30 )
52+ h .dircache .clear () # Needed for filedircache
3753
3854 # First, the directory cache is not initialized.
3955 assert not h .dircache
@@ -49,9 +65,19 @@ def test_list_cache_with_expiry_time_cached(server):
4965 out = h .glob (server + "/index/*" )
5066 assert out == [server + "/index/realfile" ]
5167
68+ h .dircache .clear () # clean up
69+
70+
71+ @pytest .mark .parametrize ("listings_cache_type" , ["memdircache" , "filedircache" ])
72+ def test_list_cache_with_expiry_time_purged (server , listings_cache_type ):
73+ h = fsspec .filesystem (
74+ "http" ,
75+ use_listings_cache = True ,
76+ listings_expiry_time = 0.3 ,
77+ listings_cache_type = listings_cache_type ,
78+ )
5279
53- def test_list_cache_with_expiry_time_purged (server ):
54- h = fsspec .filesystem ("http" , use_listings_cache = True , listings_expiry_time = 0.3 )
80+ h .dircache .clear () # Needed for filedircache
5581
5682 # First, the directory cache is not initialized.
5783 assert not h .dircache
@@ -80,9 +106,20 @@ def test_list_cache_with_expiry_time_purged(server):
80106 cached_items = h .dircache .get (server + "/index/" )
81107 assert len (cached_items ) == 1
82108
109+ h .dircache .clear () # clean up
83110
84- def test_list_cache_reuse (server ):
85- h = fsspec .filesystem ("http" , use_listings_cache = True , listings_expiry_time = 5 )
111+
112+ @pytest .mark .parametrize ("listings_cache_type" , ["memdircache" , "filedircache" ])
113+ def test_list_cache_reuse (server , listings_cache_type ):
114+ h = fsspec .filesystem (
115+ "http" ,
116+ use_listings_cache = True ,
117+ listings_expiry_time = 5 ,
118+ listings_cache_type = listings_cache_type ,
119+ )
120+
121+ # Needed for filedircache
122+ h .dircache .clear ()
86123
87124 # First, the directory cache is not initialized.
88125 assert not h .dircache
@@ -101,14 +138,26 @@ def test_list_cache_reuse(server):
101138
102139 # Verify that yet another new instance, with caching enabled,
103140 # will see the same cache content again.
104- h = fsspec .filesystem ("http" , use_listings_cache = True , listings_expiry_time = 5 )
141+ h = fsspec .filesystem (
142+ "http" ,
143+ use_listings_cache = True ,
144+ listings_expiry_time = 5 ,
145+ listings_cache_type = listings_cache_type ,
146+ )
105147 assert len (h .dircache ) == 1
106148
107149 # However, yet another instance with a different expiry time will also not have
108150 # any valid cache content.
109- h = fsspec .filesystem ("http" , use_listings_cache = True , listings_expiry_time = 666 )
151+ h = fsspec .filesystem (
152+ "http" ,
153+ use_listings_cache = True ,
154+ listings_expiry_time = 666 ,
155+ listings_cache_type = listings_cache_type ,
156+ )
110157 assert len (h .dircache ) == 0
111158
159+ h .dircache .clear () # clean up
160+
112161
113162def test_ls_raises_filenotfound (server ):
114163 h = fsspec .filesystem ("http" )
@@ -123,8 +172,14 @@ def test_list_cache_with_max_paths(server):
123172 assert out == [server + "/index/realfile" ]
124173
125174
126- def test_list_cache_with_skip_instance_cache (server ):
127- h = fsspec .filesystem ("http" , use_listings_cache = True , skip_instance_cache = True )
175+ @pytest .mark .parametrize ("listings_cache_type" , ["memdircache" , "filedircache" ])
176+ def test_list_cache_with_skip_instance_cache (server , listings_cache_type ):
177+ h = fsspec .filesystem (
178+ "http" ,
179+ use_listings_cache = True ,
180+ skip_instance_cache = True ,
181+ listings_cache_type = listings_cache_type ,
182+ )
128183 out = h .glob (server + "/index/*" )
129184 assert out == [server + "/index/realfile" ]
130185
0 commit comments