testing/example_scripts/unittest/test_unittest_asynctest.py
raw| 1 | # mypy: allow-untyped-defs |
| 2 | """Issue #7110""" |
| 3 | |
| 4 | from __future__ import annotations |
| 5 | |
| 6 | import asyncio |
| 7 | |
| 8 | import asynctest |
| 9 | |
| 10 | |
| 11 | teardowns: list[None] = [] |
| 12 | |
| 13 | |
| 14 | class Test(asynctest.TestCase): |
| 15 | async def tearDown(self): |
| 16 | teardowns.append(None) |
| 17 | |
| 18 | async def test_error(self): |
| 19 | await asyncio.sleep(0) |
| 20 | self.fail("failing on purpose") |
| 21 | |
| 22 | async def test_ok(self): |
| 23 | await asyncio.sleep(0) |
| 24 | |
| 25 | def test_teardowns(self): |
| 26 | assert len(teardowns) == 2 |