Merge pull request #7144 from nicoddemus/async-testcase-7110

This commit is contained in:
Bruno Oliveira
2020-05-01 16:44:10 -03:00
parent 32562881d4
commit da615a4fbe
9 changed files with 70 additions and 36 deletions

View File

@@ -1,7 +1,13 @@
from unittest import IsolatedAsyncioTestCase # type: ignore
teardowns = []
class AsyncArguments(IsolatedAsyncioTestCase):
async def asyncTearDown(self):
teardowns.append(None)
async def test_something_async(self):
async def addition(x, y):
return x + y
@@ -13,3 +19,6 @@ class AsyncArguments(IsolatedAsyncioTestCase):
return x + y
self.assertEqual(await addition(2, 2), 3)
def test_teardowns(self):
assert len(teardowns) == 2

View File

@@ -0,0 +1,22 @@
"""Issue #7110"""
import asyncio
import asynctest
teardowns = []
class Test(asynctest.TestCase):
async def tearDown(self):
teardowns.append(None)
async def test_error(self):
await asyncio.sleep(0)
self.fail("failing on purpose")
async def test_ok(self):
await asyncio.sleep(0)
def test_teardowns(self):
assert len(teardowns) == 2