diff --git a/homeassistant/core.py b/homeassistant/core.py index bfca43723e5..bcd96b9d3a9 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -204,8 +204,6 @@ class HomeAssistant(object): except KeyboardInterrupt: self.loop.call_soon(stop_homeassistant) self.loop.run_forever() - finally: - self.loop.close() @asyncio.coroutine def async_start(self): diff --git a/tests/common.py b/tests/common.py index fb5dab7004b..68f28cee4d3 100644 --- a/tests/common.py +++ b/tests/common.py @@ -79,8 +79,9 @@ def get_test_home_assistant(num_threads=None): with patch.object(ha, 'async_create_timer', return_value=None): with patch.object(ha, 'async_monitor_worker_pool', return_value=None): - orig_start() - hass.block_till_done() + with patch.object(hass.loop, 'add_signal_handler'): + orig_start() + hass.block_till_done() def stop_hass(): orig_stop() diff --git a/tests/test_core.py b/tests/test_core.py index ab96fc59e07..39301b5614a 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -2,8 +2,6 @@ # pylint: disable=protected-access,too-many-public-methods # pylint: disable=too-few-public-methods import asyncio -import os -import signal import unittest from unittest.mock import patch, MagicMock from datetime import datetime, timedelta @@ -15,8 +13,7 @@ from homeassistant.exceptions import InvalidEntityFormatError import homeassistant.util.dt as dt_util from homeassistant.util.unit_system import (METRIC_SYSTEM) from homeassistant.const import ( - __version__, EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP, - EVENT_STATE_CHANGED, ATTR_FRIENDLY_NAME, CONF_UNIT_SYSTEM) + __version__, EVENT_STATE_CHANGED, ATTR_FRIENDLY_NAME, CONF_UNIT_SYSTEM) from tests.common import get_test_home_assistant