mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Fix blocking process call in process tests (#121104)
Discovered by ruff in https://github.com/home-assistant/core/pull/120799
This commit is contained in:
parent
291f309c0e
commit
7958c0825e
@ -1,21 +1,26 @@
|
|||||||
"""Test process util."""
|
"""Test process util."""
|
||||||
|
|
||||||
|
from functools import partial
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.util import process
|
from homeassistant.util import process
|
||||||
|
|
||||||
|
|
||||||
async def test_kill_process() -> None:
|
async def test_kill_process(hass: HomeAssistant) -> None:
|
||||||
"""Test killing a process."""
|
"""Test killing a process."""
|
||||||
sleeper = subprocess.Popen( # noqa: S602 # shell by design
|
sleeper = await hass.async_add_executor_job(
|
||||||
|
partial( # noqa: S604 # shell by design
|
||||||
|
subprocess.Popen,
|
||||||
"sleep 1000",
|
"sleep 1000",
|
||||||
shell=True,
|
shell=True,
|
||||||
stdout=subprocess.DEVNULL,
|
stdout=subprocess.DEVNULL,
|
||||||
stderr=subprocess.DEVNULL,
|
stderr=subprocess.DEVNULL,
|
||||||
)
|
)
|
||||||
|
)
|
||||||
pid = sleeper.pid
|
pid = sleeper.pid
|
||||||
|
|
||||||
assert os.kill(pid, 0) is None
|
assert os.kill(pid, 0) is None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user