Debian Codegraph @

testing/example_scripts/unittest/test_unittest_asyncio.py

raw
1 # mypy: allow-untyped-defs
2 from __future__ import annotations
3
4 from unittest import IsolatedAsyncioTestCase
5
6
7 teardowns: list[None] = []
8
9
10 class AsyncArguments(IsolatedAsyncioTestCase):
11 async def asyncTearDown(self):
12 teardowns.append(None)
13
14 async def test_something_async(self):
15 async def addition(x, y):
16 return x + y
17
18 self.assertEqual(await addition(2, 2), 4)
19
20 async def test_something_async_fails(self):
21 async def addition(x, y):
22 return x + y
23
24 self.assertEqual(await addition(2, 2), 3)
25
26 def test_teardowns(self):
27 assert len(teardowns) == 2