Adjust Generator type hints in tests (#121013)
parent
bd234db48f
commit
faf43ed4c7
|
@ -47,7 +47,7 @@ from tests.typing import MqttMockHAClient
|
|||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def only_sensor_platform() -> Generator[[], None]:
|
||||
def only_sensor_platform() -> Generator[None]:
|
||||
"""Only setup the DROP sensor platform."""
|
||||
with patch("homeassistant.components.drop_connect.PLATFORMS", [Platform.SENSOR]):
|
||||
yield
|
||||
|
|
|
@ -104,7 +104,7 @@ def encode_access_token() -> str:
|
|||
|
||||
|
||||
@pytest.fixture(name="access_token")
|
||||
def access_token_fixture(requests_mock: Mocker) -> Generator[None, None, None]:
|
||||
def access_token_fixture(requests_mock: Mocker) -> Generator[None]:
|
||||
"""Fixture to setup the access token."""
|
||||
token_response = {
|
||||
"refresh_token": REFRESH_TOKEN,
|
||||
|
|
|
@ -4,7 +4,6 @@ from asyncio import AbstractEventLoop
|
|||
from collections.abc import Generator
|
||||
from contextlib import suppress
|
||||
import os
|
||||
from typing import Any
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
@ -19,7 +18,7 @@ from tests.common import async_capture_events
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
def iid_storage(hass):
|
||||
def iid_storage(hass: HomeAssistant) -> Generator[AccessoryIIDStorage]:
|
||||
"""Mock the iid storage."""
|
||||
with patch.object(AccessoryIIDStorage, "_async_schedule_save"):
|
||||
yield AccessoryIIDStorage(hass, "")
|
||||
|
@ -28,7 +27,7 @@ def iid_storage(hass):
|
|||
@pytest.fixture
|
||||
def run_driver(
|
||||
hass: HomeAssistant, event_loop: AbstractEventLoop, iid_storage: AccessoryIIDStorage
|
||||
) -> Generator[HomeDriver, Any, None]:
|
||||
) -> Generator[HomeDriver]:
|
||||
"""Return a custom AccessoryDriver instance for HomeKit accessory init.
|
||||
|
||||
This mock does not mock async_stop, so the driver will not be stopped
|
||||
|
@ -57,7 +56,7 @@ def run_driver(
|
|||
@pytest.fixture
|
||||
def hk_driver(
|
||||
hass: HomeAssistant, event_loop: AbstractEventLoop, iid_storage: AccessoryIIDStorage
|
||||
) -> Generator[HomeDriver, Any, None]:
|
||||
) -> Generator[HomeDriver]:
|
||||
"""Return a custom AccessoryDriver instance for HomeKit accessory init."""
|
||||
with (
|
||||
patch("pyhap.accessory_driver.AsyncZeroconf"),
|
||||
|
@ -89,7 +88,7 @@ def mock_hap(
|
|||
event_loop: AbstractEventLoop,
|
||||
iid_storage: AccessoryIIDStorage,
|
||||
mock_zeroconf: MagicMock,
|
||||
) -> Generator[HomeDriver, Any, None]:
|
||||
) -> Generator[HomeDriver]:
|
||||
"""Return a custom AccessoryDriver instance for HomeKit accessory init."""
|
||||
with (
|
||||
patch("pyhap.accessory_driver.AsyncZeroconf"),
|
||||
|
@ -128,7 +127,7 @@ def events(hass):
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
def demo_cleanup(hass):
|
||||
def demo_cleanup(hass: HomeAssistant) -> Generator[None]:
|
||||
"""Clean up device tracker demo file."""
|
||||
yield
|
||||
with suppress(FileNotFoundError):
|
||||
|
|
|
@ -77,10 +77,9 @@ def mock_room_status() -> dict[str, Any]:
|
|||
|
||||
@pytest.fixture
|
||||
def mock_incomfort(
|
||||
hass: HomeAssistant,
|
||||
mock_heater_status: dict[str, Any],
|
||||
mock_room_status: dict[str, Any],
|
||||
) -> Generator[MagicMock, None]:
|
||||
) -> Generator[MagicMock]:
|
||||
"""Mock the InComfort gateway client."""
|
||||
|
||||
class MockRoom:
|
||||
|
|
|
@ -27,7 +27,7 @@ def config_entry(hass: HomeAssistant) -> MockConfigEntry:
|
|||
@pytest.fixture
|
||||
async def mock_tibber_setup(
|
||||
config_entry: MockConfigEntry, hass: HomeAssistant
|
||||
) -> AsyncGenerator[None, MagicMock]:
|
||||
) -> AsyncGenerator[MagicMock]:
|
||||
"""Mock tibber entry setup."""
|
||||
unique_user_id = "unique_user_id"
|
||||
title = "title"
|
||||
|
|
|
@ -18,7 +18,7 @@ def banned_function():
|
|||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def patch_get_current_frame(stack: list[Mock]) -> Generator[None, None, None]:
|
||||
def patch_get_current_frame(stack: list[Mock]) -> Generator[None]:
|
||||
"""Patch get_current_frame."""
|
||||
frames = extract_stack_to_frame(stack)
|
||||
with (
|
||||
|
|
Loading…
Reference in New Issue