mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 01:07:10 +00:00
Fix contextmanager-generator-missing-cleanup warning in tests (#119478)
This commit is contained in:
parent
f7326d3baf
commit
e3e80c83b7
@ -195,9 +195,11 @@ def get_test_home_assistant() -> Generator[HomeAssistant]:
|
|||||||
|
|
||||||
threading.Thread(name="LoopThread", target=run_loop, daemon=False).start()
|
threading.Thread(name="LoopThread", target=run_loop, daemon=False).start()
|
||||||
|
|
||||||
yield hass
|
try:
|
||||||
loop.run_until_complete(context_manager.__aexit__(None, None, None))
|
yield hass
|
||||||
loop.close()
|
finally:
|
||||||
|
loop.run_until_complete(context_manager.__aexit__(None, None, None))
|
||||||
|
loop.close()
|
||||||
|
|
||||||
|
|
||||||
class StoreWithoutWriteLoad[_T: (Mapping[str, Any] | Sequence[Any])](storage.Store[_T]):
|
class StoreWithoutWriteLoad[_T: (Mapping[str, Any] | Sequence[Any])](storage.Store[_T]):
|
||||||
@ -359,10 +361,11 @@ async def async_test_home_assistant(
|
|||||||
|
|
||||||
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_CLOSE, clear_instance)
|
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_CLOSE, clear_instance)
|
||||||
|
|
||||||
yield hass
|
try:
|
||||||
|
yield hass
|
||||||
# Restore timezone, it is set when creating the hass object
|
finally:
|
||||||
dt_util.set_default_time_zone(orig_tz)
|
# Restore timezone, it is set when creating the hass object
|
||||||
|
dt_util.set_default_time_zone(orig_tz)
|
||||||
|
|
||||||
|
|
||||||
def async_mock_service(
|
def async_mock_service(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user