Protect loop set default executor (#37438)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
1 parent
f8651d9faa
commit
f49ce5d1b4
21 files changed
+387
-244
No files matched your search
+11
-14
@@ -1104,14 +1104,13 @@ def test_timer_out_of_sync(mock_monotonic, loop):
|
||||
assert abs(target - 14.2) < 0.001
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_hass_start_starts_the_timer(loop):
|
||||
async def test_hass_start_starts_the_timer(loop):
|
||||
"""Test when hass starts, it starts the timer."""
|
||||
hass = ha.HomeAssistant(loop=loop)
|
||||
hass = ha.HomeAssistant()
|
||||
|
||||
try:
|
||||
with patch("homeassistant.core._async_create_timer") as mock_timer:
|
||||
yield from hass.async_start()
|
||||
await hass.async_start()
|
||||
|
||||
assert hass.state == ha.CoreState.running
|
||||
assert not hass._track_task
|
||||
@@ -1119,21 +1118,20 @@ def test_hass_start_starts_the_timer(loop):
|
||||
assert mock_timer.mock_calls[0][1][0] is hass
|
||||
|
||||
finally:
|
||||
yield from hass.async_stop()
|
||||
await hass.async_stop()
|
||||
assert hass.state == ha.CoreState.not_running
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_start_taking_too_long(loop, caplog):
|
||||
async def test_start_taking_too_long(loop, caplog):
|
||||
"""Test when async_start takes too long."""
|
||||
hass = ha.HomeAssistant(loop=loop)
|
||||
hass = ha.HomeAssistant()
|
||||
caplog.set_level(logging.WARNING)
|
||||
|
||||
try:
|
||||
with patch(
|
||||
"homeassistant.core.timeout", side_effect=asyncio.TimeoutError
|
||||
), patch("homeassistant.core._async_create_timer") as mock_timer:
|
||||
yield from hass.async_start()
|
||||
await hass.async_start()
|
||||
|
||||
assert hass.state == ha.CoreState.running
|
||||
assert len(mock_timer.mock_calls) == 1
|
||||
@@ -1141,14 +1139,13 @@ def test_start_taking_too_long(loop, caplog):
|
||||
assert "Something is blocking Home Assistant" in caplog.text
|
||||
|
||||
finally:
|
||||
yield from hass.async_stop()
|
||||
await hass.async_stop()
|
||||
assert hass.state == ha.CoreState.not_running
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_track_task_functions(loop):
|
||||
async def test_track_task_functions(loop):
|
||||
"""Test function to start/stop track task and initial state."""
|
||||
hass = ha.HomeAssistant(loop=loop)
|
||||
hass = ha.HomeAssistant()
|
||||
try:
|
||||
assert hass._track_task
|
||||
|
||||
@@ -1158,7 +1155,7 @@ def test_track_task_functions(loop):
|
||||
hass.async_track_tasks()
|
||||
assert hass._track_task
|
||||
finally:
|
||||
yield from hass.async_stop()
|
||||
await hass.async_stop()
|
||||
|
||||
|
||||
async def test_service_executed_with_subservices(hass):
|
||||
|
||||
Reference in new issue
Block a user