Skip to content

Commit 3279199

Browse files
author
Maksym Shtembuliak
committed
test: wait for deferred HA entry reload
1 parent 308251b commit 3279199

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎tests_ha/test_ha_setup_unload.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,13 @@ async def _detected_refresh(
350350
# the second setup then materializes driver-specific entities from the
351351
# persisted identity instead of polling in the setup path.
352352
allow_detection.set()
353+
# The production reload is intentionally dispatched through call_later(0)
354+
# so it cannot race the current ConfigEntry setup success return. A bare
355+
# async_block_till_done() does not own that timer handle and can therefore
356+
# return one event-loop tick before the reload task is created.
357+
async with asyncio.timeout(5):
358+
while len(fake_runtime) < 2:
359+
await asyncio.sleep(0)
353360
await hass.async_block_till_done()
354361

355362
assert entry.state is ConfigEntryState.LOADED

0 commit comments

Comments
 (0)