Cache entity properties that are never expected to change in the base class (#95315)

This commit is contained in:
J. Nick Koston 2023-09-14 17:48:48 -05:00 committed by GitHub
parent 5f20725fd5
commit 042776ebb8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 146 additions and 48 deletions

View file

@ -98,9 +98,13 @@ class TestHelpersEntity:
def setup_method(self, method):
"""Set up things to be run when tests are started."""
self.hass = get_test_home_assistant()
self._create_entity()
def _create_entity(self) -> None:
self.entity = entity.Entity()
self.entity.entity_id = "test.overwrite_hidden_true"
self.hass = self.entity.hass = get_test_home_assistant()
self.entity.hass = self.hass
self.entity.schedule_update_ha_state()
self.hass.block_till_done()
@ -123,6 +127,7 @@ class TestHelpersEntity:
with patch(
"homeassistant.helpers.entity.Entity.device_class", new="test_class"
):
self._create_entity()
self.entity.schedule_update_ha_state()
self.hass.block_till_done()
state = self.hass.states.get(self.entity.entity_id)