diff --git a/tests/components/mqtt/test_binary_sensor.py b/tests/components/mqtt/test_binary_sensor.py index 995aadd7dba..afa9ca9970e 100644 --- a/tests/components/mqtt/test_binary_sensor.py +++ b/tests/components/mqtt/test_binary_sensor.py @@ -1173,6 +1173,8 @@ async def test_cleanup_triggers_and_restoring_state( state = hass.states.get("binary_sensor.test2") assert state.state == state2 + await hass.async_block_till_done(wait_background_tasks=True) + @pytest.mark.parametrize( "hass_config", diff --git a/tests/components/mqtt/test_device_tracker.py b/tests/components/mqtt/test_device_tracker.py index 254885919b0..76129d4c549 100644 --- a/tests/components/mqtt/test_device_tracker.py +++ b/tests/components/mqtt/test_device_tracker.py @@ -240,6 +240,8 @@ async def test_device_tracker_discovery_update( # Entity was not updated as the state was not changed assert state.last_updated == datetime(2023, 8, 22, 19, 16, tzinfo=UTC) + await hass.async_block_till_done(wait_background_tasks=True) + async def test_cleanup_device_tracker( hass: HomeAssistant, diff --git a/tests/components/mqtt/test_event.py b/tests/components/mqtt/test_event.py index 64a2003606c..fd4f8eb3e5d 100644 --- a/tests/components/mqtt/test_event.py +++ b/tests/components/mqtt/test_event.py @@ -222,6 +222,8 @@ async def test_setting_event_value_via_mqtt_json_message_and_default_current_sta assert state.attributes.get("val") == "valcontent" assert state.attributes.get("par") == "parcontent" + await hass.async_block_till_done(wait_background_tasks=True) + @pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) async def test_availability_when_connection_lost( diff --git a/tests/components/mqtt/test_mixins.py b/tests/components/mqtt/test_mixins.py index e46f0b56c15..ae4d232ba54 100644 --- a/tests/components/mqtt/test_mixins.py +++ b/tests/components/mqtt/test_mixins.py @@ -335,7 +335,7 @@ async def test_default_entity_and_device_name( # Assert that no issues ware registered assert len(events) == 0 - await hass.async_block_till_done() + await hass.async_block_till_done(wait_background_tasks=True) # Assert that no issues ware registered assert len(events) == 0