From 47680eac8f0eb1aaa1f8b826863bf7c2335a2a7f Mon Sep 17 00:00:00 2001 From: Cycloctane Date: Fri, 10 Jan 2025 05:52:59 +0800 Subject: [PATCH] Fix test that creates orphaned subprocess (#711) --- tests/test_runserver_main.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/test_runserver_main.py b/tests/test_runserver_main.py index 5e7938e9..2f0d9a9e 100644 --- a/tests/test_runserver_main.py +++ b/tests/test_runserver_main.py @@ -120,7 +120,7 @@ async def hello(request): @forked -def test_start_runserver_with_multi_app_modules(tmpworkdir, capfd): +async def test_start_runserver_with_multi_app_modules(tmpworkdir, capfd): mktree(tmpworkdir, { "app.py": f"""\ from aiohttp import web @@ -149,10 +149,13 @@ async def create_app(): app_task = AppTask(config) app_task._start_dev_server() - app_task._process.join(2) + try: + app_task._process.join(2) - captured = capfd.readouterr() - assert captured.out == "" + captured = capfd.readouterr() + assert captured.out == "" + finally: + await app_task._stop_dev_server() @forked