From 7e2a7b9393c4ddee2116a336baaa73a28bf7dcc0 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 28 Apr 2026 12:50:02 +0200 Subject: [PATCH] Fix shelly device_trigger tests (#169305) Co-authored-by: Copilot --- tests/components/shelly/test_device_trigger.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/components/shelly/test_device_trigger.py b/tests/components/shelly/test_device_trigger.py index b23f56ef4a9..b88418d71f1 100644 --- a/tests/components/shelly/test_device_trigger.py +++ b/tests/components/shelly/test_device_trigger.py @@ -402,6 +402,8 @@ async def test_rpc_no_runtime_data( ) -> None: """Test the device trigger for the RPC device when there is no runtime_data in the entry.""" entry = await init_integration(hass, 2) + # Cache initial runtime_data + runtime_data = entry.runtime_data monkeypatch.delattr(entry, "runtime_data") device = dr.async_entries_for_config_entry(device_registry, entry.entry_id)[0] @@ -437,6 +439,9 @@ async def test_rpc_no_runtime_data( assert len(service_calls) == 1 assert service_calls[0].data["some"] == "test_trigger_single_push" + # Restore runtime_data to avoid issues on cleanup + entry.runtime_data = runtime_data + async def test_block_no_runtime_data( hass: HomeAssistant, @@ -447,6 +452,8 @@ async def test_block_no_runtime_data( ) -> None: """Test the device trigger for the block device when there is no runtime_data in the entry.""" entry = await init_integration(hass, 1) + # Cache initial runtime_data + runtime_data = entry.runtime_data monkeypatch.delattr(entry, "runtime_data") device = dr.async_entries_for_config_entry(device_registry, entry.entry_id)[0] @@ -481,3 +488,6 @@ async def test_block_no_runtime_data( assert len(service_calls) == 1 assert service_calls[0].data["some"] == "test_trigger_single" + + # Restore runtime_data to avoid issues on cleanup + entry.runtime_data = runtime_data