From fcf318cf53de7efe38ab15607a2affefa9eb3eb0 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Thu, 3 Nov 2016 11:07:47 +0100 Subject: [PATCH] Bugfix windows have a other default loop now (#4195) * Bugfix windows have a other default loop now * fix handling with 3.4.2 that not support ensure_future * make the same as ensure_future does * fix spell * fix lazy test --- homeassistant/bootstrap.py | 8 ++++---- tests/components/test_group.py | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/homeassistant/bootstrap.py b/homeassistant/bootstrap.py index fdcdb5d4fe2..31e404ad87a 100644 --- a/homeassistant/bootstrap.py +++ b/homeassistant/bootstrap.py @@ -352,8 +352,8 @@ def from_config_dict(config: Dict[str, Any], future.set_exception(exc) # run task - future = asyncio.Future() - asyncio.Task(_async_init_from_config_dict(future), loop=hass.loop) + future = asyncio.Future(loop=hass.loop) + hass.loop.create_task(_async_init_from_config_dict(future)) hass.loop.run_until_complete(future) return future.result() @@ -452,8 +452,8 @@ def from_config_file(config_path: str, future.set_exception(exc) # run task - future = asyncio.Future() - asyncio.Task(_async_init_from_config_file(future), loop=hass.loop) + future = asyncio.Future(loop=hass.loop) + hass.loop.create_task(_async_init_from_config_file(future)) hass.loop.run_until_complete(future) return future.result() diff --git a/tests/components/test_group.py b/tests/components/test_group.py index 9b6d96d898f..786fee16624 100644 --- a/tests/components/test_group.py +++ b/tests/components/test_group.py @@ -368,9 +368,11 @@ class TestComponentsGroup(unittest.TestCase): # Hide the group group.set_visibility(self.hass, group_entity_id, False) group_state = self.hass.states.get(group_entity_id) + self.hass.block_till_done() self.assertTrue(group_state.attributes.get(ATTR_HIDDEN)) # Show it again group.set_visibility(self.hass, group_entity_id, True) group_state = self.hass.states.get(group_entity_id) + self.hass.block_till_done() self.assertIsNone(group_state.attributes.get(ATTR_HIDDEN))