Fix blocking process call in process tests (#121104)

Discovered by ruff in https://github.com/home-assistant/core/pull/120799
pull/120799/head
J. Nick Koston 2024-07-03 13:26:03 -07:00 committed by GitHub
parent 291f309c0e
commit 7958c0825e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 6 deletions

View File

@ -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