Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions tests/components/knx/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,12 @@ async def _init_switch_and_wait_for_first_state_updater_run(

freezer.tick(timedelta(minutes=59))
async_fire_time_changed(hass)
await hass.async_block_till_done()
await hass.async_block_till_done()
await hass.async_block_till_done(wait_background_tasks=True)
await knx.assert_no_telegram()

freezer.tick(timedelta(minutes=1)) # 60 minutes passed
async_fire_time_changed(hass)
await hass.async_block_till_done()
await hass.async_block_till_done()
await hass.async_block_till_done(wait_background_tasks=True)
Comment on lines +293 to +298
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't waiting for a HomeAssistant background task, but an xknx internal background task 😬

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I removed this one... not sure why it is still in the branch. I swear I removed it.



async def test_default_state_updater_enabled(
Expand Down
3 changes: 1 addition & 2 deletions tests/components/nest/test_media_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -1644,8 +1644,7 @@ async def test_remove_stale_media(
point_in_time = datetime.datetime.now(datetime.UTC) + datetime.timedelta(days=1)
with freeze_time(point_in_time):
async_fire_time_changed(hass, point_in_time)
await hass.async_block_till_done()
await hass.async_block_till_done()
await hass.async_block_till_done(wait_background_tasks=True)

# Verify that the event media is still present and that the extra files
# are removed. Newer media is not removed.
Expand Down
10 changes: 3 additions & 7 deletions tests/components/openrgb/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,7 @@ async def test_reconnection_on_update_failure(

freezer.tick(SCAN_INTERVAL)
async_fire_time_changed(hass)
await hass.async_block_till_done()
await hass.async_block_till_done()
await hass.async_block_till_done(wait_background_tasks=True)

# Verify that disconnect and connect were called (reconnection happened)
mock_openrgb_client.disconnect.assert_called_once()
Expand Down Expand Up @@ -295,9 +294,7 @@ async def test_reconnection_fails_second_attempt(

freezer.tick(SCAN_INTERVAL)
async_fire_time_changed(hass)
await hass.async_block_till_done()
await hass.async_block_till_done()
await hass.async_block_till_done()
await hass.async_block_till_done(wait_background_tasks=True)

# Verify that the light became unavailable after failed reconnection
state = hass.states.get("light.ene_dram")
Expand Down Expand Up @@ -340,8 +337,7 @@ async def test_normal_update_without_errors(

freezer.tick(SCAN_INTERVAL)
async_fire_time_changed(hass)
await hass.async_block_till_done()
await hass.async_block_till_done()
await hass.async_block_till_done(wait_background_tasks=True)

# Verify that disconnect and connect were NOT called (no reconnection needed)
mock_openrgb_client.disconnect.assert_not_called()
Expand Down
3 changes: 1 addition & 2 deletions tests/components/playstation_network/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ async def test_image_platform(

freezer.tick(timedelta(seconds=30))
async_fire_time_changed(hass)
await hass.async_block_till_done()
await hass.async_block_till_done()
await hass.async_block_till_done(wait_background_tasks=True)

assert (state := hass.states.get("image.testuser_avatar"))
assert state.state == "2025-06-16T00:00:30+00:00"
Expand Down
6 changes: 2 additions & 4 deletions tests/components/rflink/test_binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ def listener(event):
future = now + timedelta(seconds=35)
with freeze_time(future):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
await hass.async_block_till_done()
await hass.async_block_till_done(wait_background_tasks=True)
state = hass.states.get("binary_sensor.test2")
assert state.state == STATE_ON
assert len(events) == 2
Expand All @@ -186,8 +185,7 @@ def listener(event):
future = now + timedelta(seconds=45)
with freeze_time(future):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
await hass.async_block_till_done()
await hass.async_block_till_done(wait_background_tasks=True)
state = hass.states.get("binary_sensor.test2")
assert state.state == STATE_OFF
assert len(events) == 3
Expand Down
3 changes: 1 addition & 2 deletions tests/components/sun/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ async def test_state_change(
caplog.clear()
with freeze_time(patched_time):
async_fire_time_changed(hass, patched_time)
await hass.async_block_till_done()
await hass.async_block_till_done()
await hass.async_block_till_done(wait_background_tasks=True)

assert caplog.text.count("sun phase_update") == 1
# Called once by time listener, once from Sun.update_events
Expand Down
3 changes: 1 addition & 2 deletions tests/components/template/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1005,8 +1005,7 @@ async def test_self_referencing_entity_picture_loop(
"homeassistant.helpers.ratelimit.time.time", return_value=next_time.timestamp()
):
async_fire_time_changed(hass, next_time)
await hass.async_block_till_done()
await hass.async_block_till_done()
await hass.async_block_till_done(wait_background_tasks=True)

assert "Template loop detected" in caplog_setup_text

Expand Down
9 changes: 3 additions & 6 deletions tests/components/template/test_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -882,22 +882,19 @@ async def test_if_fires_on_time_change(
second_time = start_time.replace(minute=4, second=0)
freezer.move_to(second_time)
async_fire_time_changed(hass, second_time)
await hass.async_block_till_done()
await hass.async_block_till_done()
await hass.async_block_till_done(wait_background_tasks=True)
assert len(calls) == 1

# Trigger again (do not match template)
third_time = start_time.replace(minute=5, second=0)
freezer.move_to(third_time)
async_fire_time_changed(hass, third_time)
await hass.async_block_till_done()
await hass.async_block_till_done()
await hass.async_block_till_done(wait_background_tasks=True)
assert len(calls) == 1

# Trigger again (match template)
forth_time = start_time.replace(minute=8, second=0)
freezer.move_to(forth_time)
async_fire_time_changed(hass, forth_time)
await hass.async_block_till_done()
await hass.async_block_till_done()
await hass.async_block_till_done(wait_background_tasks=True)
assert len(calls) == 2
Loading