From 7958c0825e123008dc39ae02a7b44c2f94b5aaca Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 3 Jul 2024 13:26:03 -0700 Subject: [PATCH] Fix blocking process call in process tests (#121104) Discovered by ruff in https://github.com/home-assistant/core/pull/120799 --- tests/util/test_process.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tests/util/test_process.py b/tests/util/test_process.py index c6125b656a5..999abe0476f 100644 --- a/tests/util/test_process.py +++ b/tests/util/test_process.py @@ -1,20 +1,25 @@ """Test process util.""" +from functools import partial import os import subprocess import pytest +from homeassistant.core import HomeAssistant from homeassistant.util import process -async def test_kill_process() -> None: +async def test_kill_process(hass: HomeAssistant) -> None: """Test killing a process.""" - sleeper = subprocess.Popen( # noqa: S602 # shell by design - "sleep 1000", - shell=True, - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, + sleeper = await hass.async_add_executor_job( + partial( # noqa: S604 # shell by design + subprocess.Popen, + "sleep 1000", + shell=True, + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + ) ) pid = sleeper.pid