pytest-dev/pytest-asyncio

unused socket fixture

Closed this issue · 4 comments

I'm converting over aiohttp code to pytest-asyncio. I noticed that in addition to the unused_port fixtures, we also have an unused_port_socket (which returns the actual socket, rather than just the port number).

I'm wondering if this fixture should be included in pytest-asyncio, so we can remove it from a future release of aiohttp?

https://github.com/aio-libs/aiohttp/blob/46b557a3ffea73af2afb8c8a86be7b40550c814a/aiohttp/test_utils.py#L79-L98

Some of the low-level asyncio functions need work on socket.socket directly, so it can make sense to facilitate their creation in pytest-asyncio.

That said, what's the advantage of get_unused_port_socket compared to socket.create_server? On first sight, both seem to provide the same functionality, including the possibility to set SO_REUSEADDR.

I implemented these 7 years ago, way before 3.8's gone EOL: aio-libs/aiohttp@3d243f7.

It may be reasonable to re-evaluate what's needed.

Alright, I'll see if that can replace them.

Looks like that works. Plenty of other issues though I'm still working through.