From 7f8e2d35ad4d0d5fed82721060bafd1bafa264b8 Mon Sep 17 00:00:00 2001 From: christianwbrock Date: Mon, 9 Dec 2024 20:55:02 +0100 Subject: [PATCH] Add host parameter to aiohttp_server fixture (#10120) (#10121) Co-authored-by: ChristianWBrock --- CHANGES/10120.feature.rst | 1 + aiohttp/pytest_plugin.py | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 CHANGES/10120.feature.rst diff --git a/CHANGES/10120.feature.rst b/CHANGES/10120.feature.rst new file mode 100644 index 00000000000..98cee5650d6 --- /dev/null +++ b/CHANGES/10120.feature.rst @@ -0,0 +1 @@ +Added ``host`` parameter to ``aiohttp_server`` fixture -- by :user:`christianwbrock`. diff --git a/aiohttp/pytest_plugin.py b/aiohttp/pytest_plugin.py index 8eef2f46d44..1803257cc36 100644 --- a/aiohttp/pytest_plugin.py +++ b/aiohttp/pytest_plugin.py @@ -304,9 +304,13 @@ def aiohttp_server(loop: asyncio.AbstractEventLoop) -> Iterator[AiohttpServer]: servers = [] async def go( - app: Application, *, port: Optional[int] = None, **kwargs: Any + app: Application, + *, + host: str = "127.0.0.1", + port: Optional[int] = None, + **kwargs: Any, ) -> TestServer: - server = TestServer(app, port=port) + server = TestServer(app, host=host, port=port) await server.start_server(**kwargs) servers.append(server) return server