From c3d9d573fc99474a311aeb136c99bc9faf3dbeaa Mon Sep 17 00:00:00 2001 From: alexdonzel <37217673+alexdonzel@users.noreply.github.com> Date: Tue, 24 Nov 2026 14:52:07 +0000 Subject: [PATCH] Fix flaky go2rtc version error test (#194196) --- tests/components/go2rtc/test_init.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/components/go2rtc/test_init.py b/tests/components/go2rtc/test_init.py index d4a2af3cded7..b02fefbbea18 100644 --- a/tests/components/go2rtc/test_init.py +++ b/tests/components/go2rtc/test_init.py @@ -943,9 +943,15 @@ async def test_setup_with_version_error( expected_log_message: str, ) -> None: """Test setup integration entry fails.""" - rest_client.validate_server_version.side_effect = [None, go2rtc_error] - assert await async_setup_component(hass, DOMAIN, config) - await hass.async_block_till_done(wait_background_tasks=True) + rest_client.validate_server_version.side_effect = go2rtc_error + # The server checks the version too, at start and in its watchdog, which + # can run before the entry setup, so it gets a client of its own + with patch( + "homeassistant.components.go2rtc.server.Go2RtcRestClient", + return_value=AsyncMock(), + ): + assert await async_setup_component(hass, DOMAIN, config) + await hass.async_block_till_done(wait_background_tasks=True) config_entries = hass.config_entries.async_entries(DOMAIN) assert len(config_entries) == 1 assert config_entries[0].state is expected_config_entry_state