test_ok2/testing/example_scripts/unittest/test_unittest_asyncio.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

26 lines
617 B
Python
Raw Normal View History

# mypy: allow-untyped-defs
from typing import List
from unittest import IsolatedAsyncioTestCase
2020-10-06 09:13:05 +08:00
teardowns: List[None] = []
class AsyncArguments(IsolatedAsyncioTestCase):
async def asyncTearDown(self):
teardowns.append(None)
async def test_something_async(self):
async def addition(x, y):
return x + y
self.assertEqual(await addition(2, 2), 4)
async def test_something_async_fails(self):
async def addition(x, y):
return x + y
self.assertEqual(await addition(2, 2), 3)
def test_teardowns(self):
assert len(teardowns) == 2