@@ -81,22 +81,37 @@ async def uncached_func(x):
8181 return x
8282
8383
84- ids = ["func-bounded" , "func-unbounded" , "meth-bounded" , "meth-unbounded" ]
85- funcs = [
84+ funcs_no_ttl = [
8685 cached_func ,
8786 cached_func_unbounded ,
8887 Methods .cached_meth ,
8988 Methods .cached_meth_unbounded ,
9089]
90+ no_ttl_ids = [
91+ "func-bounded" ,
92+ "func-unbounded" ,
93+ "meth-bounded" ,
94+ "meth-unbounded" ,
95+ ]
96+
9197funcs_ttl = [
9298 cached_func_ttl ,
9399 cached_func_unbounded_ttl ,
94100 Methods .cached_meth_ttl ,
95101 Methods .cached_meth_unbounded_ttl ,
96102]
103+ ttl_ids = [
104+ "func-bounded-ttl" ,
105+ "func-unbounded-ttl" ,
106+ "meth-bounded-ttl" ,
107+ "meth-unbounded-ttl" ,
108+ ]
109+
110+ all_funcs = [* funcs_no_ttl , * funcs_ttl ]
111+ all_ids = [* no_ttl_ids , * ttl_ids ]
97112
98113
99- @pytest .mark .parametrize ("func" , funcs , ids = ids )
114+ @pytest .mark .parametrize ("func" , all_funcs , ids = all_ids )
100115def test_cache_hit_benchmark (
101116 benchmark : BenchmarkFixture ,
102117 run_loop : Callable [..., Any ],
@@ -115,7 +130,7 @@ async def run() -> None:
115130 benchmark (run_loop , run )
116131
117132
118- @pytest .mark .parametrize ("func" , funcs , ids = ids )
133+ @pytest .mark .parametrize ("func" , all_funcs , ids = all_ids )
119134def test_cache_miss_benchmark (
120135 benchmark : BenchmarkFixture ,
121136 run_loop : Callable [..., Any ],
@@ -131,7 +146,7 @@ async def run() -> None:
131146 benchmark (run_loop , run )
132147
133148
134- @pytest .mark .parametrize ("func" , funcs , ids = ids )
149+ @pytest .mark .parametrize ("func" , all_funcs , ids = all_ids )
135150def test_cache_clear_benchmark (
136151 benchmark : BenchmarkFixture ,
137152 run_loop : Callable [..., Any ],
@@ -143,7 +158,7 @@ def test_cache_clear_benchmark(
143158 benchmark (func .cache_clear )
144159
145160
146- @pytest .mark .parametrize ("func_ttl" , funcs_ttl , ids = ids )
161+ @pytest .mark .parametrize ("func_ttl" , funcs_ttl , ids = ttl_ids )
147162def test_cache_ttl_expiry_benchmark (
148163 benchmark : BenchmarkFixture ,
149164 run_loop : Callable [..., Any ],
@@ -155,7 +170,7 @@ def test_cache_ttl_expiry_benchmark(
155170 benchmark (run_loop , func_ttl , 99 )
156171
157172
158- @pytest .mark .parametrize ("func" , funcs , ids = ids )
173+ @pytest .mark .parametrize ("func" , all_funcs , ids = all_ids )
159174def test_cache_invalidate_benchmark (
160175 benchmark : BenchmarkFixture ,
161176 run_loop : Callable [..., Any ],
@@ -174,7 +189,7 @@ def run() -> None:
174189 invalidate (i )
175190
176191
177- @pytest .mark .parametrize ("func" , funcs , ids = ids )
192+ @pytest .mark .parametrize ("func" , all_funcs , ids = all_ids )
178193def test_cache_info_benchmark (
179194 benchmark : BenchmarkFixture ,
180195 run_loop : Callable [..., Any ],
@@ -193,7 +208,7 @@ def run() -> None:
193208 cache_info ()
194209
195210
196- @pytest .mark .parametrize ("func" , funcs , ids = ids )
211+ @pytest .mark .parametrize ("func" , all_funcs , ids = all_ids )
197212def test_concurrent_cache_hit_benchmark (
198213 benchmark : BenchmarkFixture ,
199214 run_loop : Callable [..., Any ],
@@ -236,11 +251,12 @@ async def fill():
236251
237252# The relevant internal methods do not exist on _LRUCacheWrapperInstanceMethod,
238253# so we can skip methods for this part of the benchmark suite.
239- only_funcs = funcs [:2 ]
240- func_ids = ids [:2 ]
254+ # We also skip wrappers with ttl because it raises KeyError.
255+ only_funcs_no_ttl = all_funcs [:2 ]
256+ func_ids_no_ttl = all_ids [:2 ]
241257
242258
243- @pytest .mark .parametrize ("func" , only_funcs , ids = func_ids )
259+ @pytest .mark .parametrize ("func" , only_funcs_no_ttl , ids = func_ids_no_ttl )
244260def test_internal_cache_hit_microbenchmark (
245261 benchmark : BenchmarkFixture ,
246262 run_loop : Callable [..., Any ],
@@ -260,7 +276,7 @@ def run() -> None:
260276 cache_hit (i )
261277
262278
263- @pytest .mark .parametrize ("func" , only_funcs , ids = func_ids )
279+ @pytest .mark .parametrize ("func" , only_funcs_no_ttl , ids = func_ids_no_ttl )
264280def test_internal_cache_miss_microbenchmark (
265281 benchmark : BenchmarkFixture , func : _LRUCacheWrapper [Any ]
266282) -> None :
@@ -273,7 +289,7 @@ def run() -> None:
273289 cache_miss (i )
274290
275291
276- @pytest .mark .parametrize ("func" , only_funcs , ids = func_ids )
292+ @pytest .mark .parametrize ("func" , only_funcs_no_ttl , ids = func_ids_no_ttl )
277293@pytest .mark .parametrize ("task_state" , ["finished" , "cancelled" , "exception" ])
278294def test_internal_task_done_callback_microbenchmark (
279295 benchmark : BenchmarkFixture ,
0 commit comments