From 4950bda40662290b218b81158199e708d5d81b89 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Mon, 14 Apr 2025 23:32:52 +0200 Subject: [PATCH] Fix homeaticip_cloud RuntimeWarnings (#142961) --- .../components/homematicip_cloud/test_hap.py | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/tests/components/homematicip_cloud/test_hap.py b/tests/components/homematicip_cloud/test_hap.py index 8f56c2e0b99..1732459149c 100644 --- a/tests/components/homematicip_cloud/test_hap.py +++ b/tests/components/homematicip_cloud/test_hap.py @@ -129,10 +129,6 @@ async def test_hap_reset_unloads_entry_if_setup( assert hass.data[HMIPC_DOMAIN] == {} -@patch( - "homeassistant.components.homematicip_cloud.hap.ConnectionContextBuilder.build_context_async", - return_value=ConnectionContext(), -) async def test_hap_create( hass: HomeAssistant, hmip_config_entry: MockConfigEntry, simple_mock_home ) -> None: @@ -140,15 +136,17 @@ async def test_hap_create( hass.config.components.add(HMIPC_DOMAIN) hap = HomematicipHAP(hass, hmip_config_entry) assert hap - with patch.object(hap, "async_connect"): + with ( + patch( + "homeassistant.components.homematicip_cloud.hap.ConnectionContextBuilder.build_context_async", + return_value=ConnectionContext(), + ), + patch.object(hap, "async_connect"), + ): async with hmip_config_entry.setup_lock: assert await hap.async_setup() -@patch( - "homeassistant.components.homematicip_cloud.hap.ConnectionContextBuilder.build_context_async", - return_value=ConnectionContext(), -) async def test_hap_create_exception( hass: HomeAssistant, hmip_config_entry: MockConfigEntry, mock_connection_init ) -> None: @@ -158,13 +156,23 @@ async def test_hap_create_exception( hap = HomematicipHAP(hass, hmip_config_entry) assert hap - with patch( - "homeassistant.components.homematicip_cloud.hap.AsyncHome.get_current_state_async", - side_effect=Exception, + with ( + patch( + "homeassistant.components.homematicip_cloud.hap.ConnectionContextBuilder.build_context_async", + return_value=ConnectionContext(), + ), + patch( + "homeassistant.components.homematicip_cloud.hap.AsyncHome.get_current_state_async", + side_effect=Exception, + ), ): assert not await hap.async_setup() with ( + patch( + "homeassistant.components.homematicip_cloud.hap.ConnectionContextBuilder.build_context_async", + return_value=ConnectionContext(), + ), patch( "homeassistant.components.homematicip_cloud.hap.AsyncHome.get_current_state_async", side_effect=HmipConnectionError,