asynctest icon indicating copy to clipboard operation
asynctest copied to clipboard

failure with uvloop and @fail_on

Open janhn opened this issue 6 years ago • 1 comments

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)

janhn avatar Mar 14 '18 14:03 janhn

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.

Martiusweb avatar Mar 24 '18 10:03 Martiusweb