Adjust thread safety check messages to point to developer docs (#117392)

This commit is contained in:
J. Nick Koston
2024-05-14 22:20:31 +09:00
committed by GitHub
parent 77de1b2331
commit 7871e9279b
17 changed files with 57 additions and 50 deletions

View File

@@ -3442,7 +3442,8 @@ async def test_async_fire_thread_safety(hass: HomeAssistant) -> None:
events = async_capture_events(hass, "test_event")
hass.bus.async_fire("test_event")
with pytest.raises(
RuntimeError, match="Detected code that calls async_fire from a thread."
RuntimeError,
match="Detected code that calls hass.bus.async_fire from a thread.",
):
await hass.async_add_executor_job(hass.bus.async_fire, "test_event")
@@ -3452,7 +3453,8 @@ async def test_async_fire_thread_safety(hass: HomeAssistant) -> None:
async def test_async_register_thread_safety(hass: HomeAssistant) -> None:
"""Test async_register thread safety."""
with pytest.raises(
RuntimeError, match="Detected code that calls async_register from a thread."
RuntimeError,
match="Detected code that calls hass.services.async_register from a thread.",
):
await hass.async_add_executor_job(
hass.services.async_register,
@@ -3465,7 +3467,8 @@ async def test_async_register_thread_safety(hass: HomeAssistant) -> None:
async def test_async_remove_thread_safety(hass: HomeAssistant) -> None:
"""Test async_remove thread safety."""
with pytest.raises(
RuntimeError, match="Detected code that calls async_remove from a thread."
RuntimeError,
match="Detected code that calls hass.services.async_remove from a thread.",
):
await hass.async_add_executor_job(
hass.services.async_remove, "test_domain", "test_service"
@@ -3479,6 +3482,7 @@ async def test_async_create_task_thread_safety(hass: HomeAssistant) -> None:
pass
with pytest.raises(
RuntimeError, match="Detected code that calls async_create_task from a thread."
RuntimeError,
match="Detected code that calls hass.async_create_task from a thread.",
):
await hass.async_add_executor_job(hass.async_create_task, _any_coro)