@@ -30,7 +30,7 @@ def test_cache(a: int, b: int, expected: int) -> None:
3030 """Test that the cache decorator works correctly for synchronous functions."""
3131 calls : dict [tuple [int , int ], int ] = defaultdict (int )
3232
33- @cache (storage = lambda : TTLMapStorage (max_size = 1000 , ttl = timedelta (seconds = 1 )))
33+ @cache (storage = TTLMapStorage . create_with (max_size = 1000 , ttl = timedelta (seconds = 1 )))
3434 def func (x : int , y : int ) -> int :
3535 nonlocal calls
3636 calls [(x , y )] += 1
@@ -120,7 +120,7 @@ def test_cache_dog_piling_sync(a: int, b: int, expected: int, workers_count: int
120120 """
121121 calls = 0
122122
123- @cache (storage = lambda : TTLMapStorage (max_size = 1000 , ttl = timedelta (seconds = 1 )))
123+ @cache (storage = TTLMapStorage . create_with (max_size = 1000 , ttl = timedelta (seconds = 1 )))
124124 def func (x : int , y : int ) -> int :
125125 time .sleep (0.1 )
126126 nonlocal calls
@@ -153,7 +153,7 @@ def test_cache_failing_func_sync(a: int, b: int, workers_count: int) -> None:
153153 """Test that failing functions are not cached in synchronous context."""
154154 calls = 0
155155
156- @cache (storage = lambda : TTLMapStorage (max_size = 1000 , ttl = timedelta (seconds = 1 )))
156+ @cache (storage = TTLMapStorage . create_with (max_size = 1000 , ttl = timedelta (seconds = 1 )))
157157 def func (x : int , y : int ) -> int :
158158 time .sleep (0.03 )
159159 nonlocal calls
@@ -226,7 +226,7 @@ def _f() -> None:
226226@pytest .mark .parametrize (
227227 ("func" , "storage" ),
228228 [
229- (_af , lambda : TTLMapStorage (max_size = 1000 , ttl = timedelta (seconds = 1 ))),
229+ (_af , TTLMapStorage . create_with (max_size = 1000 , ttl = timedelta (seconds = 1 ))),
230230 (_f , lambda : TTLMapAsyncStorage (max_size = 1000 , ttl = timedelta (seconds = 1 ))),
231231 ],
232232)
@@ -239,7 +239,7 @@ def test__decorator__invalid_storage(func: Callable[..., Any], storage: PStorage
239239def test__decorator__cache_only_by_chosen_args ():
240240 calls : dict [tuple [str , int , float ], int ] = defaultdict (int )
241241
242- @cache (storage = lambda : TTLMapStorage (max_size = 1000 , ttl = timedelta (seconds = 1 )))
242+ @cache (storage = TTLMapStorage . create_with (max_size = 1000 , ttl = timedelta (seconds = 1 )))
243243 def func (a : Annotated [str , CacheWith ()], b : int , c : Annotated [float , CacheWith ]) -> str :
244244 nonlocal calls
245245 calls [(a , b , c )] += 1
0 commit comments