mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 17:27:52 +00:00
Remove ConfigEntry runtime_data on unload (#117312)
This commit is contained in:
parent
a1bc929421
commit
3434fb70fb
@ -127,6 +127,4 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Unload Teslemetry Config."""
|
||||
if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
|
||||
del entry.runtime_data
|
||||
return unload_ok
|
||||
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||
|
@ -802,6 +802,8 @@ class ConfigEntry(Generic[_DataT]):
|
||||
if domain_is_integration:
|
||||
if result:
|
||||
self._async_set_state(hass, ConfigEntryState.NOT_LOADED, None)
|
||||
if hasattr(self, "runtime_data"):
|
||||
object.__delattr__(self, "runtime_data")
|
||||
|
||||
await self._async_process_on_unload(hass)
|
||||
except Exception as exc:
|
||||
|
@ -1581,6 +1581,7 @@ async def test_entry_unload_succeed(
|
||||
"""Test that we can unload an entry."""
|
||||
entry = MockConfigEntry(domain="comp", state=config_entries.ConfigEntryState.LOADED)
|
||||
entry.add_to_hass(hass)
|
||||
entry.runtime_data = 2
|
||||
|
||||
async_unload_entry = AsyncMock(return_value=True)
|
||||
|
||||
@ -1589,6 +1590,7 @@ async def test_entry_unload_succeed(
|
||||
assert await manager.async_unload(entry.entry_id)
|
||||
assert len(async_unload_entry.mock_calls) == 1
|
||||
assert entry.state is config_entries.ConfigEntryState.NOT_LOADED
|
||||
assert not hasattr(entry, "runtime_data")
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
Loading…
x
Reference in New Issue
Block a user