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:
epenet
2023-02-08 08:51:43 +01:00
committed by GitHub
parent 1bbc03d0ba
commit c98b4e3204
50 changed files with 816 additions and 671 deletions

View File

@@ -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