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
|
import pytest
from web_poet.utils import memoizemethod_noargs, cached_method
@pytest.mark.mypy_testing
def test_memoizemethod_noargs():
class Foo:
@memoizemethod_noargs
def meth(self) -> str:
return ''
foo = Foo()
reveal_type(foo.meth()) # R: builtins.str
@pytest.mark.mypy_testing
def test_cached_method_sync():
class Foo:
@cached_method
def meth(self) -> str:
return ''
foo = Foo()
reveal_type(foo.meth()) # R: builtins.str
@pytest.mark.mypy_testing
async def test_cached_method_async():
class Foo:
@cached_method
async def meth(self) -> str:
return ''
foo = Foo()
reveal_type(await foo.meth()) # R: builtins.str
|