@@ -26,14 +26,30 @@ def test_list_invalid_args(server):
26
26
h .glob (server + "/index/*" )
27
27
28
28
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
+
31
37
out = h .glob (server + "/index/*" )
32
38
assert out == [server + "/index/realfile" ]
33
39
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
+ )
34
51
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
37
53
38
54
# First, the directory cache is not initialized.
39
55
assert not h .dircache
@@ -49,9 +65,19 @@ def test_list_cache_with_expiry_time_cached(server):
49
65
out = h .glob (server + "/index/*" )
50
66
assert out == [server + "/index/realfile" ]
51
67
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
+ )
52
79
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
55
81
56
82
# First, the directory cache is not initialized.
57
83
assert not h .dircache
@@ -80,9 +106,20 @@ def test_list_cache_with_expiry_time_purged(server):
80
106
cached_items = h .dircache .get (server + "/index/" )
81
107
assert len (cached_items ) == 1
82
108
109
+ h .dircache .clear () # clean up
83
110
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 ()
86
123
87
124
# First, the directory cache is not initialized.
88
125
assert not h .dircache
@@ -101,14 +138,26 @@ def test_list_cache_reuse(server):
101
138
102
139
# Verify that yet another new instance, with caching enabled,
103
140
# 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
+ )
105
147
assert len (h .dircache ) == 1
106
148
107
149
# However, yet another instance with a different expiry time will also not have
108
150
# 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
+ )
110
157
assert len (h .dircache ) == 0
111
158
159
+ h .dircache .clear () # clean up
160
+
112
161
113
162
def test_ls_raises_filenotfound (server ):
114
163
h = fsspec .filesystem ("http" )
@@ -123,8 +172,14 @@ def test_list_cache_with_max_paths(server):
123
172
assert out == [server + "/index/realfile" ]
124
173
125
174
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
+ )
128
183
out = h .glob (server + "/index/*" )
129
184
assert out == [server + "/index/realfile" ]
130
185
0 commit comments