Instead of trying to handle unittest-async functions in pytest_pyfunc_call, let the unittest framework handle them instead. This lets us remove the hack in pytest_pyfunc_call, with the upside that we should support any unittest-async based framework. Also included 'asynctest' as test dependency for py37-twisted, and renamed 'twisted' to 'unittestextras' to better reflect that we install 'twisted' and 'asynctest' now. This also fixes the problem of cleanUp functions not being properly called for async functions. Fix #7110 Fix #6924
25 lines
571 B
Python
25 lines
571 B
Python
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
|
|
|
|
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
|