pnuckowski / aioresponses

Aioresponses is a helper for mock/fake web requests in python aiohttp package.
MIT License
513 stars 86 forks source link

tests/test_aioresponses.py::AIOResponsesTestCase::test_callback_coroutine fails with python3.11 #215

Open mgorny opened 2 years ago

mgorny commented 2 years ago

When running the test suite under Python 3.11.0b3, I get the following failure:

____________________________________________ AIOResponsesTestCase.test_callback_coroutine _____________________________________________

self = <tests.test_aioresponses.AIOResponsesTestCase testMethod=test_callback_coroutine>
m = <aioresponses.core.aioresponses object at 0x7fdcc0556390>

    @aioresponses()
    def test_callback_coroutine(self, m):
        body = b'New body'
        event = asyncio.Event()

        async def callback(url, **kwargs):
            await event.wait()
            self.assertEqual(str(url), self.url)
            self.assertEqual(kwargs, {'allow_redirects': True})
            return CallbackResult(body=body)

        m.get(self.url, callback=callback)
        future = asyncio.ensure_future(self.request(self.url))
        self.run_async(asyncio.wait([future], timeout=0))
        assert not future.done()
        event.set()
        self.run_async(asyncio.wait([future], timeout=0))
>       assert future.done()
E       AssertionError: assert False
E        +  where False = <built-in method done of _asyncio.Task object at 0x7fdcbfc96080>()
E        +    where <built-in method done of _asyncio.Task object at 0x7fdcbfc96080> = <Task pending name='Task-25' coro=<AIOResponsesTestCase.request() running at /tmp/aioresponses/tests/test_aioresponses.py:49>>.done

tests/test_aioresponses.py:490: AssertionError

This is on Gentoo Linux. I can reproduce with git master @ 8242acc91f112a9a877f61aa3ff32bc791509e95.