File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,29 @@ def test_indirect_call() -> None:
107107 with assertRaises(MyError):
108108 asyncio.run(indirect_call_3(ident(-113.0, True)))
109109
110+ class C:
111+ def __init__(self, n: int) -> None:
112+ self.n = n
113+
114+ async def add(self, x: int, err: bool = False) -> int:
115+ await asyncio.sleep(0)
116+ if err:
117+ raise MyError()
118+ return x + self.n
119+
120+ async def method_call(x: int) -> int:
121+ c = C(5)
122+ return await c.add(x)
123+
124+ async def method_call_exception() -> int:
125+ c = C(5)
126+ return await c.add(3, err=True)
127+
128+ def test_async_method_call() -> None:
129+ assert asyncio.run(method_call(3)) == 8
130+ with assertRaises(MyError):
131+ asyncio.run(method_call_exception())
132+
110133[file asyncio/__init__.pyi]
111134async def sleep(t: float) -> None: ...
112135# eh, we could use the real type but it doesn't seem important
You can’t perform that action at this time.
0 commit comments