1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
from functools import _CacheInfo
from typing import Callable
import pytest
from async_lru import _R, _LRUCacheWrapper
@pytest.fixture
def check_lru() -> Callable[..., None]:
def _check_lru(
wrapped: _LRUCacheWrapper[_R],
*,
hits: int,
misses: int,
cache: int,
tasks: int,
maxsize: int = 128
) -> None:
assert wrapped.cache_info() == _CacheInfo(
hits=hits,
misses=misses,
maxsize=maxsize,
currsize=cache,
)
assert wrapped.cache_parameters()["tasks"] == tasks
return _check_lru
|