mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Fix cancel propagation in update coordinator and config entry (#153504)
This commit is contained in:
@@ -9727,3 +9727,31 @@ async def test_config_flow_create_entry_with_next_flow(hass: HomeAssistant) -> N
|
||||
assert result["next_flow"][0] == config_entries.FlowType.CONFIG_FLOW
|
||||
# Verify the target flow exists
|
||||
hass.config_entries.flow.async_get(result["next_flow"][1])
|
||||
|
||||
|
||||
async def test_canceled_exceptions_are_propagated(
|
||||
hass: HomeAssistant, manager: config_entries.ConfigEntries
|
||||
) -> None:
|
||||
"""Tests that base exceptions like cancellations are not swallowed."""
|
||||
entry = MockConfigEntry(title="test_title", domain="test")
|
||||
start = asyncio.Event()
|
||||
abort = asyncio.Event()
|
||||
|
||||
async def _setup(_: HomeAssistant, __: ConfigEntry) -> bool:
|
||||
start.set()
|
||||
await abort.wait()
|
||||
return True
|
||||
|
||||
mock_integration(hass, MockModule("test", async_setup_entry=_setup))
|
||||
mock_platform(hass, "test.config_flow", None)
|
||||
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
task = hass.async_create_task(manager.async_setup(entry.entry_id))
|
||||
await start.wait()
|
||||
task.cancel()
|
||||
|
||||
with pytest.raises(asyncio.CancelledError):
|
||||
await task
|
||||
|
||||
abort.set()
|
||||
|
||||
Reference in New Issue
Block a user