Skip to content

Commit

Permalink
Test classmethod (#512)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamsorcerer authored Jul 31, 2023
1 parent 7e0c7ca commit 17211d9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ testpaths = tests/
junit_family=xunit2
asyncio_mode=auto
timeout=15

xfail_strict = true

[mypy]
strict=True
Expand Down
24 changes: 24 additions & 0 deletions tests/test_basic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import asyncio
import platform
import sys
from functools import _CacheInfo, partial
from typing import Callable

Expand Down Expand Up @@ -188,6 +190,28 @@ async def coro(self) -> int:
)


@pytest.mark.xfail(
sys.version_info[:2] == (3, 9) and platform.python_implementation() != "PyPy",
reason="#511",
)
async def test_alru_cache_classmethod() -> None:
class A:
offset = 3

@classmethod
@alru_cache
async def coro(cls, val: int) -> int:
return val + cls.offset

assert await A.coro(5) == 8
assert A.coro.cache_parameters() == _CacheParameters(
typed=False,
maxsize=128,
tasks=0,
closed=False,
)


async def test_invalidate_cache_for_method() -> None:
class A:
@alru_cache
Expand Down

0 comments on commit 17211d9

Please sign in to comment.