Deprecated stuff (#16019)

* Use async with for locks

* Fix regex in template test

* Close session correctly

* Use correct current_task method

* push camera cleanup

* Lint

* Revert current_task

* Update websocket_api.py

* Mock executor_job betteR

* Fix async_create_task mock
This commit is contained in:
Paulus Schoutsen 2018-08-20 16:34:18 +02:00 committed by GitHub
parent 975befd136
commit d1e1b9b38a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 50 additions and 22 deletions

View file

@ -12,6 +12,8 @@ from yarl import URL
from aiohttp.client_exceptions import ClientResponseError
from homeassistant.const import EVENT_HOMEASSISTANT_CLOSE
retype = type(re.compile(''))
@ -216,7 +218,18 @@ def mock_aiohttp_client():
"""Context manager to mock aiohttp client."""
mocker = AiohttpClientMocker()
def create_session(hass, *args):
session = mocker.create_session(hass.loop)
async def close_session(event):
"""Close session."""
await session.close()
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_CLOSE, close_session)
return session
with mock.patch(
'homeassistant.helpers.aiohttp_client.async_create_clientsession',
side_effect=lambda hass, *args: mocker.create_session(hass.loop)):
side_effect=create_session):
yield mocker