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