From 51cdda86baead26080f774c400f81492b62022f6 Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Mon, 9 Dec 2024 20:12:25 +0000 Subject: [PATCH] Add host parameter to aiohttp_server fixture (#10120) (#10121) (#10150) Co-authored-by: ChristianWBrock (cherry picked from commit 7f8e2d35ad4d0d5fed82721060bafd1bafa264b8) 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 7ce60faa4a4..158fd684b7a 100644 --- a/aiohttp/pytest_plugin.py +++ b/aiohttp/pytest_plugin.py @@ -301,9 +301,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(loop=loop, **kwargs) servers.append(server) return server