File: test_utils.mypy-testing

package info (click to toggle)
python-web-poet 0.23.2-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 908 kB
  • sloc: python: 6,112; makefile: 19
file content (36 lines) | stat: -rw-r--r-- 748 bytes parent folder | download | duplicates (3)
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