From 3d1751bdfa85e979ab157dcab721bbc965c1c440 Mon Sep 17 00:00:00 2001 From: Michael <35783820+mib1185@users.noreply.github.com> Date: Mon, 22 Jan 2024 20:26:46 +0100 Subject: [PATCH] Prevent runtime issue during entity registration in coordinator of AVM Fritz!Tools (#108667) prevent dictionary changed size during iteration --- homeassistant/components/fritz/common.py | 6 ++++-- tests/components/fritz/test_update.py | 3 --- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/fritz/common.py b/homeassistant/components/fritz/common.py index bad73d91320..55bf7279ede 100644 --- a/homeassistant/components/fritz/common.py +++ b/homeassistant/components/fritz/common.py @@ -315,12 +315,14 @@ class FritzBoxTools( } try: await self.async_scan_devices() - for key, update_fn in self._entity_update_functions.items(): + for key in list(self._entity_update_functions): _LOGGER.debug("update entity %s", key) entity_data["entity_states"][ key ] = await self.hass.async_add_executor_job( - update_fn, self.fritz_status, self.data["entity_states"].get(key) + self._entity_update_functions[key], + self.fritz_status, + self.data["entity_states"].get(key), ) if self.has_call_deflections: entity_data[ diff --git a/tests/components/fritz/test_update.py b/tests/components/fritz/test_update.py index 5cb9d4d3d69..bc677e28ebe 100644 --- a/tests/components/fritz/test_update.py +++ b/tests/components/fritz/test_update.py @@ -2,8 +2,6 @@ from unittest.mock import patch -import pytest - from homeassistant.components.fritz.const import DOMAIN from homeassistant.components.update import DOMAIN as UPDATE_DOMAIN from homeassistant.config_entries import ConfigEntryState @@ -49,7 +47,6 @@ async def test_update_entities_initialized( assert len(updates) == 1 -@pytest.mark.xfail(reason="Flaky test") async def test_update_available( hass: HomeAssistant, hass_client: ClientSessionGenerator,