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:
1 parent
975befd136
commit
d1e1b9b38a
7 files changed
+50
-22
No files matched your search
@@ -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
|
||||
Reference in new issue
Block a user