Prevent ping integration from blocking startup (#38504)

This commit is contained in:
J. Nick Koston authored and GitHub committed 2020-08-05 12:43:35 +02:00
1 parent 3fdec7946c
commit a91f5b7192
6 files changed
+69 -8

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
"""Test process util."""
import os
import subprocess
import pytest
from homeassistant.util import process
async def test_kill_process():
"""Test killing a process."""
sleeper = subprocess.Popen(
"sleep 1000",
shell=True, # nosec # shell by design
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
pid = sleeper.pid
assert os.kill(pid, 0) is None
process.kill_subprocess(sleeper)
with pytest.raises(OSError):
os.kill(pid, 0)