mirror of
https://github.com/home-assistant/core.git
synced 2025-11-07 18:09:31 +00:00
Add typing to tests with single hass argument (2) (#87675)
* Add typing to tests with single hass argument (2) * a few more
This commit is contained in:
@@ -6,6 +6,7 @@ from unittest.mock import MagicMock, Mock, patch
|
||||
import pytest
|
||||
|
||||
from homeassistant import block_async_io
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.util import async_ as hasync
|
||||
|
||||
|
||||
@@ -239,7 +240,7 @@ async def test_gather_with_concurrency() -> None:
|
||||
assert results == [2, 2, -1, -1]
|
||||
|
||||
|
||||
async def test_shutdown_run_callback_threadsafe(hass):
|
||||
async def test_shutdown_run_callback_threadsafe(hass: HomeAssistant) -> None:
|
||||
"""Test we can shutdown run_callback_threadsafe."""
|
||||
hasync.shutdown_run_callback_threadsafe(hass.loop)
|
||||
callback = MagicMock()
|
||||
@@ -248,7 +249,7 @@ async def test_shutdown_run_callback_threadsafe(hass):
|
||||
hasync.run_callback_threadsafe(hass.loop, callback)
|
||||
|
||||
|
||||
async def test_run_callback_threadsafe(hass):
|
||||
async def test_run_callback_threadsafe(hass: HomeAssistant) -> None:
|
||||
"""Test run_callback_threadsafe runs code in the event loop."""
|
||||
it_ran = False
|
||||
|
||||
@@ -265,7 +266,7 @@ async def test_run_callback_threadsafe(hass):
|
||||
assert it_ran is True
|
||||
|
||||
|
||||
async def test_callback_is_always_scheduled(hass):
|
||||
async def test_callback_is_always_scheduled(hass: HomeAssistant) -> None:
|
||||
"""Test run_callback_threadsafe always calls call_soon_threadsafe before checking for shutdown."""
|
||||
# We have to check the shutdown state AFTER the callback is scheduled otherwise
|
||||
# the function could continue on and the caller call `future.result()` after
|
||||
|
||||
Reference in New Issue
Block a user