mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Ensure MockEntityPlatform shuts down after tests (#89849)
This commit is contained in:
parent
aa72b48725
commit
abd91dd934
@ -37,6 +37,7 @@ from homeassistant.config import async_process_component_config
|
|||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
DEVICE_DEFAULT_NAME,
|
DEVICE_DEFAULT_NAME,
|
||||||
EVENT_HOMEASSISTANT_CLOSE,
|
EVENT_HOMEASSISTANT_CLOSE,
|
||||||
|
EVENT_HOMEASSISTANT_STOP,
|
||||||
EVENT_STATE_CHANGED,
|
EVENT_STATE_CHANGED,
|
||||||
STATE_OFF,
|
STATE_OFF,
|
||||||
STATE_ON,
|
STATE_ON,
|
||||||
@ -757,7 +758,7 @@ class MockEntityPlatform(entity_platform.EntityPlatform):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
hass,
|
hass: HomeAssistant,
|
||||||
logger=None,
|
logger=None,
|
||||||
domain="test_domain",
|
domain="test_domain",
|
||||||
platform_name="test_platform",
|
platform_name="test_platform",
|
||||||
@ -783,6 +784,11 @@ class MockEntityPlatform(entity_platform.EntityPlatform):
|
|||||||
entity_namespace=entity_namespace,
|
entity_namespace=entity_namespace,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
async def _async_on_stop(_: Event) -> None:
|
||||||
|
await self.async_shutdown()
|
||||||
|
|
||||||
|
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, _async_on_stop)
|
||||||
|
|
||||||
|
|
||||||
class MockToggleEntity(entity.ToggleEntity):
|
class MockToggleEntity(entity.ToggleEntity):
|
||||||
"""Provide a mock toggle device."""
|
"""Provide a mock toggle device."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user