1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| from asyncio import sleep from unittest import IsolatedAsyncioTestCase
async def add(a, b) -> int: await sleep(1) return a + b
async def get_test_case(x) -> tuple[int, int]: await sleep(1) return x, 2*x
@parameterized_class(('testcase_func', 'testcase_param', 'answer'), [ (staticmethod(get_test_case), 2, 6), (staticmethod(get_test_case), 3, 9), ]) class TestClass1(IsolatedAsyncioTestCase): a: int b: int
async def asyncSetup(self) -> None: self.a, self.b = await self.testcase_func(testcase_param)
async def test_add() -> None: self.assertEqual(add(self.a, self.b), self.answer)
|