asynctest
asynctest copied to clipboard
failure with uvloop and @fail_on
While testing with uvloop, the @fail_on decorator seems to rely on the internals of the default asyncio loop:
import asyncio
import asynctest
import uvloop
# make calls to asyncio.get_event_loop() return an instance of uvloop
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
@asynctest.fail_on(active_handles=True)
class TestFailOn(asynctest.TestCase):
"""
This raises in asynctest with:
AttributeError: 'Loop' object has no attribute '_scheduled'
at .../asynctest/_fail_on.py:88
"""
use_default_loop = True
async def test_async_task(self):
await asyncio.sleep(0)
Yes, the public API of asyncio doesn't expose enough methods to implement these features.
Unfortunately, fixing this is complicated and I've no plans yet.