From 5d9dc8252b5d08fffac3e8f9cdd54246defb1301 Mon Sep 17 00:00:00 2001 From: Jan Bouwhuis Date: Mon, 9 May 2022 11:52:08 +0200 Subject: [PATCH] Use helper for testing an event change (#71579) --- tests/components/mqtt/test_discovery.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tests/components/mqtt/test_discovery.py b/tests/components/mqtt/test_discovery.py index a1ef6ea477a..9215ab651b2 100644 --- a/tests/components/mqtt/test_discovery.py +++ b/tests/components/mqtt/test_discovery.py @@ -24,6 +24,7 @@ from homeassistant.setup import async_setup_component from tests.common import ( MockConfigEntry, + async_capture_events, async_fire_mqtt_message, mock_device_registry, mock_entity_platform, @@ -438,14 +439,7 @@ async def test_rediscover(hass, mqtt_mock, caplog): async def test_rapid_rediscover(hass, mqtt_mock, caplog): """Test immediate rediscover of removed component.""" - events = [] - - @ha.callback - def callback(event): - """Verify event got called.""" - events.append(event) - - hass.bus.async_listen(EVENT_STATE_CHANGED, callback) + events = async_capture_events(hass, EVENT_STATE_CHANGED) async_fire_mqtt_message( hass,