-
-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathconftest.py
More file actions
39 lines (30 loc) · 800 Bytes
/
conftest.py
File metadata and controls
39 lines (30 loc) · 800 Bytes
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
29
30
31
32
33
34
35
36
37
38
39
import sys
from functools import _CacheInfo
from typing import Callable, TypeVar
import pytest
from async_lru import _LRUCacheWrapper
if sys.version_info >= (3, 10):
from typing import ParamSpec
else:
from typing_extensions import ParamSpec
_T = TypeVar("_T")
_P = ParamSpec("_P")
@pytest.fixture
def check_lru() -> Callable[..., None]:
def _check_lru(
wrapped: _LRUCacheWrapper[_P, _T],
*,
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