Import Generator from typing_extensions (3) (#118990)

This commit is contained in:
Marc Mueller 2024-06-06 17:28:59 +02:00 committed by GitHub
parent 0ecab967dd
commit 33ed4fd862
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
93 changed files with 258 additions and 257 deletions

View File

@ -1,6 +1,6 @@
"""Common fixtures for the Gardena Bluetooth tests.""" """Common fixtures for the Gardena Bluetooth tests."""
from collections.abc import Awaitable, Callable, Generator from collections.abc import Awaitable, Callable
from typing import Any from typing import Any
from unittest.mock import AsyncMock, Mock, patch from unittest.mock import AsyncMock, Mock, patch
@ -10,6 +10,7 @@ from gardena_bluetooth.const import DeviceInformation
from gardena_bluetooth.exceptions import CharacteristicNotFound from gardena_bluetooth.exceptions import CharacteristicNotFound
from gardena_bluetooth.parse import Characteristic from gardena_bluetooth.parse import Characteristic
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.gardena_bluetooth.const import DOMAIN from homeassistant.components.gardena_bluetooth.const import DOMAIN
from homeassistant.components.gardena_bluetooth.coordinator import SCAN_INTERVAL from homeassistant.components.gardena_bluetooth.coordinator import SCAN_INTERVAL
@ -30,7 +31,7 @@ def mock_entry():
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry.""" """Override async_setup_entry."""
with patch( with patch(
"homeassistant.components.gardena_bluetooth.async_setup_entry", "homeassistant.components.gardena_bluetooth.async_setup_entry",

View File

@ -1,9 +1,9 @@
"""Configuration for GeoJSON Events tests.""" """Configuration for GeoJSON Events tests."""
from collections.abc import Generator
from unittest.mock import AsyncMock, patch from unittest.mock import AsyncMock, patch
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.geo_json_events import DOMAIN from homeassistant.components.geo_json_events import DOMAIN
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, CONF_RADIUS, CONF_URL from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, CONF_RADIUS, CONF_URL
@ -30,7 +30,7 @@ def config_entry() -> MockConfigEntry:
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Mock geo_json_events entry setup.""" """Mock geo_json_events entry setup."""
with patch( with patch(
"homeassistant.components.geo_json_events.async_setup_entry", return_value=True "homeassistant.components.geo_json_events.async_setup_entry", return_value=True

View File

@ -2,11 +2,11 @@
from __future__ import annotations from __future__ import annotations
from collections.abc import Generator
from unittest.mock import AsyncMock, MagicMock, patch from unittest.mock import AsyncMock, MagicMock, patch
from geocachingapi import GeocachingStatus from geocachingapi import GeocachingStatus
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.geocaching.const import DOMAIN from homeassistant.components.geocaching.const import DOMAIN
@ -28,7 +28,7 @@ def mock_config_entry() -> MockConfigEntry:
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Mock setting up a config entry.""" """Mock setting up a config entry."""
with patch( with patch(
"homeassistant.components.geocaching.async_setup_entry", return_value=True "homeassistant.components.geocaching.async_setup_entry", return_value=True

View File

@ -1,9 +1,9 @@
"""conftest for the GitHub integration.""" """conftest for the GitHub integration."""
from collections.abc import Generator
from unittest.mock import patch from unittest.mock import patch
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.github.const import CONF_REPOSITORIES, DOMAIN from homeassistant.components.github.const import CONF_REPOSITORIES, DOMAIN
from homeassistant.const import CONF_ACCESS_TOKEN from homeassistant.const import CONF_ACCESS_TOKEN
@ -27,7 +27,7 @@ def mock_config_entry() -> MockConfigEntry:
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[None, None, None]: def mock_setup_entry() -> Generator[None]:
"""Mock setting up a config entry.""" """Mock setting up a config entry."""
with patch("homeassistant.components.github.async_setup_entry", return_value=True): with patch("homeassistant.components.github.async_setup_entry", return_value=True):
yield yield

View File

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
from collections.abc import AsyncGenerator, Awaitable, Callable, Generator from collections.abc import Awaitable, Callable
import datetime import datetime
import http import http
import time import time
@ -13,6 +13,7 @@ from aiohttp.client_exceptions import ClientError
from gcal_sync.auth import API_BASE_URL from gcal_sync.auth import API_BASE_URL
from oauth2client.client import OAuth2Credentials from oauth2client.client import OAuth2Credentials
import pytest import pytest
from typing_extensions import AsyncGenerator, Generator
import yaml import yaml
from homeassistant.components.application_credentials import ( from homeassistant.components.application_credentials import (
@ -29,7 +30,7 @@ from tests.test_util.aiohttp import AiohttpClientMocker
type ApiResult = Callable[[dict[str, Any]], None] type ApiResult = Callable[[dict[str, Any]], None]
type ComponentSetup = Callable[[], Awaitable[bool]] type ComponentSetup = Callable[[], Awaitable[bool]]
type AsyncYieldFixture[_T] = AsyncGenerator[_T, None] type AsyncYieldFixture[_T] = AsyncGenerator[_T]
CALENDAR_ID = "qwertyuiopasdfghjklzxcvbnm@import.calendar.google.com" CALENDAR_ID = "qwertyuiopasdfghjklzxcvbnm@import.calendar.google.com"
@ -150,7 +151,7 @@ def calendars_config(calendars_config_entity: dict[str, Any]) -> list[dict[str,
def mock_calendars_yaml( def mock_calendars_yaml(
hass: HomeAssistant, hass: HomeAssistant,
calendars_config: list[dict[str, Any]], calendars_config: list[dict[str, Any]],
) -> Generator[Mock, None, None]: ) -> Generator[Mock]:
"""Fixture that prepares the google_calendars.yaml mocks.""" """Fixture that prepares the google_calendars.yaml mocks."""
mocked_open_function = mock_open( mocked_open_function = mock_open(
read_data=yaml.dump(calendars_config) if calendars_config else None read_data=yaml.dump(calendars_config) if calendars_config else None

View File

@ -1,10 +1,10 @@
"""Test the Google Sheets config flow.""" """Test the Google Sheets config flow."""
from collections.abc import Generator
from unittest.mock import Mock, patch from unittest.mock import Mock, patch
from gspread import GSpreadException from gspread import GSpreadException
import pytest import pytest
from typing_extensions import Generator
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.components.application_credentials import ( from homeassistant.components.application_credentials import (
@ -41,7 +41,7 @@ async def setup_credentials(hass: HomeAssistant) -> None:
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
async def mock_client() -> Generator[Mock, None, None]: async def mock_client() -> Generator[Mock]:
"""Fixture to setup a fake spreadsheet client library.""" """Fixture to setup a fake spreadsheet client library."""
with patch( with patch(
"homeassistant.components.google_sheets.config_flow.Client" "homeassistant.components.google_sheets.config_flow.Client"

View File

@ -1,11 +1,11 @@
"""Test the Google Tasks config flow.""" """Test the Google Tasks config flow."""
from collections.abc import Generator
from unittest.mock import Mock, patch from unittest.mock import Mock, patch
from googleapiclient.errors import HttpError from googleapiclient.errors import HttpError
from httplib2 import Response from httplib2 import Response
import pytest import pytest
from typing_extensions import Generator
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.components.google_tasks.const import ( from homeassistant.components.google_tasks.const import (
@ -32,7 +32,7 @@ def user_identifier() -> str:
@pytest.fixture @pytest.fixture
def setup_userinfo(user_identifier: str) -> Generator[Mock, None, None]: def setup_userinfo(user_identifier: str) -> Generator[Mock]:
"""Set up userinfo.""" """Set up userinfo."""
with patch("homeassistant.components.google_tasks.config_flow.build") as mock: with patch("homeassistant.components.google_tasks.config_flow.build") as mock:
mock.return_value.userinfo.return_value.get.return_value.execute.return_value = { mock.return_value.userinfo.return_value.get.return_value.execute.return_value = {

View File

@ -1,13 +1,13 @@
"""Common fixtures for the Google Translate text-to-speech tests.""" """Common fixtures for the Google Translate text-to-speech tests."""
from collections.abc import Generator
from unittest.mock import AsyncMock, patch from unittest.mock import AsyncMock, patch
import pytest import pytest
from typing_extensions import Generator
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry.""" """Override async_setup_entry."""
with patch( with patch(
"homeassistant.components.google_translate.async_setup_entry", return_value=True "homeassistant.components.google_translate.async_setup_entry", return_value=True

View File

@ -2,7 +2,6 @@
from __future__ import annotations from __future__ import annotations
from collections.abc import Generator
from http import HTTPStatus from http import HTTPStatus
from pathlib import Path from pathlib import Path
from typing import Any from typing import Any
@ -10,6 +9,7 @@ from unittest.mock import MagicMock, patch
from gtts import gTTSError from gtts import gTTSError
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components import tts from homeassistant.components import tts
from homeassistant.components.google_translate.const import CONF_TLD, DOMAIN from homeassistant.components.google_translate.const import CONF_TLD, DOMAIN
@ -54,7 +54,7 @@ async def setup_internal_url(hass: HomeAssistant) -> None:
@pytest.fixture @pytest.fixture
def mock_gtts() -> Generator[MagicMock, None, None]: def mock_gtts() -> Generator[MagicMock]:
"""Mock gtts.""" """Mock gtts."""
with patch("homeassistant.components.google_translate.tts.gTTS") as mock_gtts: with patch("homeassistant.components.google_translate.tts.gTTS") as mock_gtts:
yield mock_gtts yield mock_gtts

View File

@ -1,11 +1,11 @@
"""Tests configuration for Govee Local API.""" """Tests configuration for Govee Local API."""
from asyncio import Event from asyncio import Event
from collections.abc import Generator
from unittest.mock import AsyncMock, MagicMock, patch from unittest.mock import AsyncMock, MagicMock, patch
from govee_local_api import GoveeLightCapability from govee_local_api import GoveeLightCapability
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.govee_light_local.coordinator import GoveeController from homeassistant.components.govee_light_local.coordinator import GoveeController
@ -25,7 +25,7 @@ def fixture_mock_govee_api():
@pytest.fixture(name="mock_setup_entry") @pytest.fixture(name="mock_setup_entry")
def fixture_mock_setup_entry() -> Generator[AsyncMock, None, None]: def fixture_mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry.""" """Override async_setup_entry."""
with patch( with patch(
"homeassistant.components.govee_light_local.async_setup_entry", "homeassistant.components.govee_light_local.async_setup_entry",

View File

@ -1,13 +1,13 @@
"""Common fixtures for the GPSD tests.""" """Common fixtures for the GPSD tests."""
from collections.abc import Generator
from unittest.mock import AsyncMock, patch from unittest.mock import AsyncMock, patch
import pytest import pytest
from typing_extensions import Generator
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry.""" """Override async_setup_entry."""
with patch( with patch(
"homeassistant.components.gpsd.async_setup_entry", return_value=True "homeassistant.components.gpsd.async_setup_entry", return_value=True

View File

@ -1,15 +1,15 @@
"""Pytest module configuration.""" """Pytest module configuration."""
from collections.abc import Generator
from unittest.mock import AsyncMock, patch from unittest.mock import AsyncMock, patch
import pytest import pytest
from typing_extensions import Generator
from .common import FakeDiscovery, build_device_mock from .common import FakeDiscovery, build_device_mock
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry.""" """Override async_setup_entry."""
with patch( with patch(
"homeassistant.components.gree.async_setup_entry", return_value=True "homeassistant.components.gree.async_setup_entry", return_value=True

View File

@ -1,10 +1,10 @@
"""Common fixtures for testing greeneye_monitor.""" """Common fixtures for testing greeneye_monitor."""
from collections.abc import Generator
from typing import Any from typing import Any
from unittest.mock import AsyncMock, MagicMock, patch from unittest.mock import AsyncMock, MagicMock, patch
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.greeneye_monitor import DOMAIN from homeassistant.components.greeneye_monitor import DOMAIN
from homeassistant.components.sensor import SensorDeviceClass from homeassistant.components.sensor import SensorDeviceClass
@ -99,7 +99,7 @@ def assert_sensor_registered(
@pytest.fixture @pytest.fixture
def monitors() -> Generator[AsyncMock, None, None]: def monitors() -> Generator[AsyncMock]:
"""Provide a mock greeneye.Monitors object that has listeners and can add new monitors.""" """Provide a mock greeneye.Monitors object that has listeners and can add new monitors."""
with patch("greeneye.Monitors", autospec=True) as mock_monitors: with patch("greeneye.Monitors", autospec=True) as mock_monitors:
mock = mock_monitors.return_value mock = mock_monitors.return_value

View File

@ -1,10 +1,10 @@
"""Define fixtures for Elexa Guardian tests.""" """Define fixtures for Elexa Guardian tests."""
from collections.abc import Generator
import json import json
from unittest.mock import AsyncMock, patch from unittest.mock import AsyncMock, patch
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.guardian import CONF_UID, DOMAIN from homeassistant.components.guardian import CONF_UID, DOMAIN
from homeassistant.const import CONF_IP_ADDRESS, CONF_PORT from homeassistant.const import CONF_IP_ADDRESS, CONF_PORT
@ -14,7 +14,7 @@ from tests.common import MockConfigEntry, load_fixture
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry.""" """Override async_setup_entry."""
with patch( with patch(
"homeassistant.components.guardian.async_setup_entry", return_value=True "homeassistant.components.guardian.async_setup_entry", return_value=True

View File

@ -3,12 +3,12 @@
from __future__ import annotations from __future__ import annotations
import asyncio import asyncio
from collections.abc import Generator
import logging import logging
from typing import Any from typing import Any
from unittest.mock import AsyncMock, call, patch from unittest.mock import AsyncMock, call, patch
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.hassio.addon_manager import ( from homeassistant.components.hassio.addon_manager import (
AddonError, AddonError,
@ -56,7 +56,7 @@ def mock_addon_installed(
@pytest.fixture(name="get_addon_discovery_info") @pytest.fixture(name="get_addon_discovery_info")
def get_addon_discovery_info_fixture() -> Generator[AsyncMock, None, None]: def get_addon_discovery_info_fixture() -> Generator[AsyncMock]:
"""Mock get add-on discovery info.""" """Mock get add-on discovery info."""
with patch( with patch(
"homeassistant.components.hassio.addon_manager.async_get_addon_discovery_info" "homeassistant.components.hassio.addon_manager.async_get_addon_discovery_info"
@ -65,7 +65,7 @@ def get_addon_discovery_info_fixture() -> Generator[AsyncMock, None, None]:
@pytest.fixture(name="addon_store_info") @pytest.fixture(name="addon_store_info")
def addon_store_info_fixture() -> Generator[AsyncMock, None, None]: def addon_store_info_fixture() -> Generator[AsyncMock]:
"""Mock Supervisor add-on store info.""" """Mock Supervisor add-on store info."""
with patch( with patch(
"homeassistant.components.hassio.addon_manager.async_get_addon_store_info" "homeassistant.components.hassio.addon_manager.async_get_addon_store_info"
@ -80,7 +80,7 @@ def addon_store_info_fixture() -> Generator[AsyncMock, None, None]:
@pytest.fixture(name="addon_info") @pytest.fixture(name="addon_info")
def addon_info_fixture() -> Generator[AsyncMock, None, None]: def addon_info_fixture() -> Generator[AsyncMock]:
"""Mock Supervisor add-on info.""" """Mock Supervisor add-on info."""
with patch( with patch(
"homeassistant.components.hassio.addon_manager.async_get_addon_info", "homeassistant.components.hassio.addon_manager.async_get_addon_info",
@ -97,7 +97,7 @@ def addon_info_fixture() -> Generator[AsyncMock, None, None]:
@pytest.fixture(name="set_addon_options") @pytest.fixture(name="set_addon_options")
def set_addon_options_fixture() -> Generator[AsyncMock, None, None]: def set_addon_options_fixture() -> Generator[AsyncMock]:
"""Mock set add-on options.""" """Mock set add-on options."""
with patch( with patch(
"homeassistant.components.hassio.addon_manager.async_set_addon_options" "homeassistant.components.hassio.addon_manager.async_set_addon_options"
@ -106,7 +106,7 @@ def set_addon_options_fixture() -> Generator[AsyncMock, None, None]:
@pytest.fixture(name="install_addon") @pytest.fixture(name="install_addon")
def install_addon_fixture() -> Generator[AsyncMock, None, None]: def install_addon_fixture() -> Generator[AsyncMock]:
"""Mock install add-on.""" """Mock install add-on."""
with patch( with patch(
"homeassistant.components.hassio.addon_manager.async_install_addon" "homeassistant.components.hassio.addon_manager.async_install_addon"
@ -115,7 +115,7 @@ def install_addon_fixture() -> Generator[AsyncMock, None, None]:
@pytest.fixture(name="uninstall_addon") @pytest.fixture(name="uninstall_addon")
def uninstall_addon_fixture() -> Generator[AsyncMock, None, None]: def uninstall_addon_fixture() -> Generator[AsyncMock]:
"""Mock uninstall add-on.""" """Mock uninstall add-on."""
with patch( with patch(
"homeassistant.components.hassio.addon_manager.async_uninstall_addon" "homeassistant.components.hassio.addon_manager.async_uninstall_addon"
@ -124,7 +124,7 @@ def uninstall_addon_fixture() -> Generator[AsyncMock, None, None]:
@pytest.fixture(name="start_addon") @pytest.fixture(name="start_addon")
def start_addon_fixture() -> Generator[AsyncMock, None, None]: def start_addon_fixture() -> Generator[AsyncMock]:
"""Mock start add-on.""" """Mock start add-on."""
with patch( with patch(
"homeassistant.components.hassio.addon_manager.async_start_addon" "homeassistant.components.hassio.addon_manager.async_start_addon"
@ -133,7 +133,7 @@ def start_addon_fixture() -> Generator[AsyncMock, None, None]:
@pytest.fixture(name="restart_addon") @pytest.fixture(name="restart_addon")
def restart_addon_fixture() -> Generator[AsyncMock, None, None]: def restart_addon_fixture() -> Generator[AsyncMock]:
"""Mock restart add-on.""" """Mock restart add-on."""
with patch( with patch(
"homeassistant.components.hassio.addon_manager.async_restart_addon" "homeassistant.components.hassio.addon_manager.async_restart_addon"
@ -142,7 +142,7 @@ def restart_addon_fixture() -> Generator[AsyncMock, None, None]:
@pytest.fixture(name="stop_addon") @pytest.fixture(name="stop_addon")
def stop_addon_fixture() -> Generator[AsyncMock, None, None]: def stop_addon_fixture() -> Generator[AsyncMock]:
"""Mock stop add-on.""" """Mock stop add-on."""
with patch( with patch(
"homeassistant.components.hassio.addon_manager.async_stop_addon" "homeassistant.components.hassio.addon_manager.async_stop_addon"
@ -151,7 +151,7 @@ def stop_addon_fixture() -> Generator[AsyncMock, None, None]:
@pytest.fixture(name="create_backup") @pytest.fixture(name="create_backup")
def create_backup_fixture() -> Generator[AsyncMock, None, None]: def create_backup_fixture() -> Generator[AsyncMock]:
"""Mock create backup.""" """Mock create backup."""
with patch( with patch(
"homeassistant.components.hassio.addon_manager.async_create_backup" "homeassistant.components.hassio.addon_manager.async_create_backup"
@ -160,7 +160,7 @@ def create_backup_fixture() -> Generator[AsyncMock, None, None]:
@pytest.fixture(name="update_addon") @pytest.fixture(name="update_addon")
def mock_update_addon() -> Generator[AsyncMock, None, None]: def mock_update_addon() -> Generator[AsyncMock]:
"""Mock update add-on.""" """Mock update add-on."""
with patch( with patch(
"homeassistant.components.hassio.addon_manager.async_update_addon" "homeassistant.components.hassio.addon_manager.async_update_addon"

View File

@ -1,13 +1,13 @@
"""Common fixtures for the Holiday tests.""" """Common fixtures for the Holiday tests."""
from collections.abc import Generator
from unittest.mock import AsyncMock, patch from unittest.mock import AsyncMock, patch
import pytest import pytest
from typing_extensions import Generator
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry.""" """Override async_setup_entry."""
with patch( with patch(
"homeassistant.components.holiday.async_setup_entry", return_value=True "homeassistant.components.holiday.async_setup_entry", return_value=True

View File

@ -1,14 +1,14 @@
"""Test fixtures for the Home Assistant Hardware integration.""" """Test fixtures for the Home Assistant Hardware integration."""
from collections.abc import Generator
from typing import Any from typing import Any
from unittest.mock import AsyncMock, MagicMock, patch from unittest.mock import AsyncMock, MagicMock, patch
import pytest import pytest
from typing_extensions import Generator
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def mock_zha_config_flow_setup() -> Generator[None, None, None]: def mock_zha_config_flow_setup() -> Generator[None]:
"""Mock the radio connection and probing of the ZHA config flow.""" """Mock the radio connection and probing of the ZHA config flow."""
def mock_probe(config: dict[str, Any]) -> None: def mock_probe(config: dict[str, Any]) -> None:
@ -39,7 +39,7 @@ def mock_zha_config_flow_setup() -> Generator[None, None, None]:
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def mock_zha_get_last_network_settings() -> Generator[None, None, None]: def mock_zha_get_last_network_settings() -> Generator[None]:
"""Mock zha.api.async_get_last_network_settings.""" """Mock zha.api.async_get_last_network_settings."""
with patch( with patch(

View File

@ -2,11 +2,11 @@
from __future__ import annotations from __future__ import annotations
from collections.abc import Generator
from typing import Any from typing import Any
from unittest.mock import AsyncMock, Mock, patch from unittest.mock import AsyncMock, Mock, patch
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.hassio import AddonError, AddonInfo, AddonState, HassIO from homeassistant.components.hassio import AddonError, AddonInfo, AddonState, HassIO
from homeassistant.components.hassio.handler import HassioAPIError from homeassistant.components.hassio.handler import HassioAPIError
@ -96,7 +96,7 @@ class FakeOptionsFlow(silabs_multiprotocol_addon.OptionsFlowHandler):
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def config_flow_handler( def config_flow_handler(
hass: HomeAssistant, current_request_with_host: None hass: HomeAssistant, current_request_with_host: None
) -> Generator[None, None, None]: ) -> Generator[None]:
"""Fixture for a test config flow.""" """Fixture for a test config flow."""
mock_platform(hass, f"{TEST_DOMAIN}.config_flow") mock_platform(hass, f"{TEST_DOMAIN}.config_flow")
with mock_config_flow(TEST_DOMAIN, FakeConfigFlow): with mock_config_flow(TEST_DOMAIN, FakeConfigFlow):
@ -104,7 +104,7 @@ def config_flow_handler(
@pytest.fixture @pytest.fixture
def options_flow_poll_addon_state() -> Generator[None, None, None]: def options_flow_poll_addon_state() -> Generator[None]:
"""Fixture for patching options flow addon state polling.""" """Fixture for patching options flow addon state polling."""
with patch( with patch(
"homeassistant.components.homeassistant_hardware.silabs_multiprotocol_addon.WaitingAddonManager.async_wait_until_addon_state" "homeassistant.components.homeassistant_hardware.silabs_multiprotocol_addon.WaitingAddonManager.async_wait_until_addon_state"
@ -113,7 +113,7 @@ def options_flow_poll_addon_state() -> Generator[None, None, None]:
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def hassio_integration(hass: HomeAssistant) -> Generator[None, None, None]: def hassio_integration(hass: HomeAssistant) -> Generator[None]:
"""Fixture to mock the `hassio` integration.""" """Fixture to mock the `hassio` integration."""
mock_component(hass, "hassio") mock_component(hass, "hassio")
hass.data["hassio"] = Mock(spec_set=HassIO) hass.data["hassio"] = Mock(spec_set=HassIO)
@ -148,7 +148,7 @@ class MockMultiprotocolPlatform(MockPlatform):
@pytest.fixture @pytest.fixture
def mock_multiprotocol_platform( def mock_multiprotocol_platform(
hass: HomeAssistant, hass: HomeAssistant,
) -> Generator[FakeConfigFlow, None, None]: ) -> Generator[FakeConfigFlow]:
"""Fixture for a test silabs multiprotocol platform.""" """Fixture for a test silabs multiprotocol platform."""
hass.config.components.add(TEST_DOMAIN) hass.config.components.add(TEST_DOMAIN)
platform = MockMultiprotocolPlatform() platform = MockMultiprotocolPlatform()

View File

@ -1,13 +1,13 @@
"""Test fixtures for the Home Assistant SkyConnect integration.""" """Test fixtures for the Home Assistant SkyConnect integration."""
from collections.abc import Generator
from unittest.mock import AsyncMock, MagicMock, patch from unittest.mock import AsyncMock, MagicMock, patch
import pytest import pytest
from typing_extensions import Generator
@pytest.fixture(name="mock_usb_serial_by_id", autouse=True) @pytest.fixture(name="mock_usb_serial_by_id", autouse=True)
def mock_usb_serial_by_id_fixture() -> Generator[MagicMock, None, None]: def mock_usb_serial_by_id_fixture() -> Generator[MagicMock]:
"""Mock usb serial by id.""" """Mock usb serial by id."""
with patch( with patch(
"homeassistant.components.zha.config_flow.usb.get_serial_by_id" "homeassistant.components.zha.config_flow.usb.get_serial_by_id"
@ -39,7 +39,7 @@ def mock_zha():
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def mock_zha_get_last_network_settings() -> Generator[None, None, None]: def mock_zha_get_last_network_settings() -> Generator[None]:
"""Mock zha.api.async_get_last_network_settings.""" """Mock zha.api.async_get_last_network_settings."""
with patch( with patch(

View File

@ -1,14 +1,14 @@
"""Test fixtures for the Home Assistant Yellow integration.""" """Test fixtures for the Home Assistant Yellow integration."""
from collections.abc import Generator
from typing import Any from typing import Any
from unittest.mock import AsyncMock, MagicMock, patch from unittest.mock import AsyncMock, MagicMock, patch
import pytest import pytest
from typing_extensions import Generator
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def mock_zha_config_flow_setup() -> Generator[None, None, None]: def mock_zha_config_flow_setup() -> Generator[None]:
"""Mock the radio connection and probing of the ZHA config flow.""" """Mock the radio connection and probing of the ZHA config flow."""
def mock_probe(config: dict[str, Any]) -> None: def mock_probe(config: dict[str, Any]) -> None:
@ -39,7 +39,7 @@ def mock_zha_config_flow_setup() -> Generator[None, None, None]:
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def mock_zha_get_last_network_settings() -> Generator[None, None, None]: def mock_zha_get_last_network_settings() -> Generator[None]:
"""Mock zha.api.async_get_last_network_settings.""" """Mock zha.api.async_get_last_network_settings."""
with patch( with patch(

View File

@ -1,9 +1,9 @@
"""Test the Home Assistant Yellow config flow.""" """Test the Home Assistant Yellow config flow."""
from collections.abc import Generator
from unittest.mock import Mock, patch from unittest.mock import Mock, patch
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.hassio import DOMAIN as HASSIO_DOMAIN from homeassistant.components.hassio import DOMAIN as HASSIO_DOMAIN
from homeassistant.components.homeassistant_yellow.const import DOMAIN from homeassistant.components.homeassistant_yellow.const import DOMAIN
@ -16,7 +16,7 @@ from tests.common import MockConfigEntry, MockModule, mock_integration
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def config_flow_handler(hass: HomeAssistant) -> Generator[None, None, None]: def config_flow_handler(hass: HomeAssistant) -> Generator[None]:
"""Fixture for a test config flow.""" """Fixture for a test config flow."""
with patch( with patch(
"homeassistant.components.homeassistant_hardware.silabs_multiprotocol_addon.WaitingAddonManager.async_wait_until_addon_state" "homeassistant.components.homeassistant_hardware.silabs_multiprotocol_addon.WaitingAddonManager.async_wait_until_addon_state"

View File

@ -1,6 +1,5 @@
"""HomeKit controller session fixtures.""" """HomeKit controller session fixtures."""
from collections.abc import Generator
import datetime import datetime
import unittest.mock import unittest.mock
@ -8,6 +7,7 @@ from aiohomekit.testing import FakeController
from freezegun import freeze_time from freezegun import freeze_time
from freezegun.api import FrozenDateTimeFactory from freezegun.api import FrozenDateTimeFactory
import pytest import pytest
from typing_extensions import Generator
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
@ -17,7 +17,7 @@ pytest.register_assert_rewrite("tests.components.homekit_controller.common")
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def freeze_time_in_future() -> Generator[FrozenDateTimeFactory, None, None]: def freeze_time_in_future() -> Generator[FrozenDateTimeFactory]:
"""Freeze time at a known point.""" """Freeze time at a known point."""
now = dt_util.utcnow() now = dt_util.utcnow()
start_dt = datetime.datetime(now.year + 1, 1, 1, 0, 0, 0, tzinfo=now.tzinfo) start_dt = datetime.datetime(now.year + 1, 1, 1, 0, 0, 0, tzinfo=now.tzinfo)

View File

@ -1,11 +1,11 @@
"""Fixtures for HomeWizard integration tests.""" """Fixtures for HomeWizard integration tests."""
from collections.abc import Generator
from unittest.mock import AsyncMock, MagicMock, patch from unittest.mock import AsyncMock, MagicMock, patch
from homewizard_energy.errors import NotFoundError from homewizard_energy.errors import NotFoundError
from homewizard_energy.models import Data, Device, State, System from homewizard_energy.models import Data, Device, State, System
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.homewizard.const import DOMAIN from homeassistant.components.homewizard.const import DOMAIN
from homeassistant.const import CONF_IP_ADDRESS from homeassistant.const import CONF_IP_ADDRESS
@ -62,7 +62,7 @@ def mock_homewizardenergy(
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Mock setting up a config entry.""" """Mock setting up a config entry."""
with patch( with patch(
"homeassistant.components.homewizard.async_setup_entry", return_value=True "homeassistant.components.homewizard.async_setup_entry", return_value=True
@ -102,7 +102,7 @@ async def init_integration(
@pytest.fixture @pytest.fixture
def mock_onboarding() -> Generator[MagicMock, None, None]: def mock_onboarding() -> Generator[MagicMock]:
"""Mock that Home Assistant is currently onboarding.""" """Mock that Home Assistant is currently onboarding."""
with patch( with patch(
"homeassistant.components.onboarding.async_is_onboarded", "homeassistant.components.onboarding.async_is_onboarded",

View File

@ -1,9 +1,9 @@
"""Common fixtures for the Lutron Homeworks Series 4 and 8 tests.""" """Common fixtures for the Lutron Homeworks Series 4 and 8 tests."""
from collections.abc import Generator
from unittest.mock import AsyncMock, MagicMock, patch from unittest.mock import AsyncMock, MagicMock, patch
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.homeworks.const import ( from homeassistant.components.homeworks.const import (
CONF_ADDR, CONF_ADDR,
@ -103,7 +103,7 @@ def mock_homeworks() -> Generator[None, MagicMock, None]:
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry.""" """Override async_setup_entry."""
with patch( with patch(
"homeassistant.components.homeworks.async_setup_entry", return_value=True "homeassistant.components.homeworks.async_setup_entry", return_value=True

View File

@ -1,10 +1,10 @@
"""Common fixtures for Hunter Douglas Powerview tests.""" """Common fixtures for Hunter Douglas Powerview tests."""
from collections.abc import Generator
from unittest.mock import AsyncMock, MagicMock, PropertyMock, patch from unittest.mock import AsyncMock, MagicMock, PropertyMock, patch
from aiopvapi.resources.shade import ShadePosition from aiopvapi.resources.shade import ShadePosition
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.hunterdouglas_powerview.const import DOMAIN from homeassistant.components.hunterdouglas_powerview.const import DOMAIN
@ -12,7 +12,7 @@ from tests.common import load_json_object_fixture, load_json_value_fixture
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry.""" """Override async_setup_entry."""
with patch( with patch(
"homeassistant.components.hunterdouglas_powerview.async_setup_entry", "homeassistant.components.hunterdouglas_powerview.async_setup_entry",
@ -29,7 +29,7 @@ def mock_hunterdouglas_hub(
rooms_json: str, rooms_json: str,
scenes_json: str, scenes_json: str,
shades_json: str, shades_json: str,
) -> Generator[MagicMock, None, None]: ) -> Generator[MagicMock]:
"""Return a mocked Powerview Hub with all data populated.""" """Return a mocked Powerview Hub with all data populated."""
with ( with (
patch( patch(

View File

@ -1,6 +1,5 @@
"""Test helpers for Husqvarna Automower.""" """Test helpers for Husqvarna Automower."""
from collections.abc import Generator
import time import time
from unittest.mock import AsyncMock, patch from unittest.mock import AsyncMock, patch
@ -8,6 +7,7 @@ from aioautomower.session import AutomowerSession, _MowerCommands
from aioautomower.utils import mower_list_to_dictionary_dataclass from aioautomower.utils import mower_list_to_dictionary_dataclass
from aiohttp import ClientWebSocketResponse from aiohttp import ClientWebSocketResponse
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.application_credentials import ( from homeassistant.components.application_credentials import (
ClientCredential, ClientCredential,
@ -81,7 +81,7 @@ async def setup_credentials(hass: HomeAssistant) -> None:
@pytest.fixture @pytest.fixture
def mock_automower_client() -> Generator[AsyncMock, None, None]: def mock_automower_client() -> Generator[AsyncMock]:
"""Mock a Husqvarna Automower client.""" """Mock a Husqvarna Automower client."""
mower_dict = mower_list_to_dictionary_dataclass( mower_dict = mower_list_to_dictionary_dataclass(

View File

@ -1,6 +1,6 @@
"""Common fixtures for the Hydrawise tests.""" """Common fixtures for the Hydrawise tests."""
from collections.abc import Awaitable, Callable, Generator from collections.abc import Awaitable, Callable
from datetime import datetime, timedelta from datetime import datetime, timedelta
from unittest.mock import AsyncMock, patch from unittest.mock import AsyncMock, patch
@ -19,6 +19,7 @@ from pydrawise.schema import (
Zone, Zone,
) )
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.hydrawise.const import DOMAIN from homeassistant.components.hydrawise.const import DOMAIN
from homeassistant.const import CONF_API_KEY, CONF_PASSWORD, CONF_USERNAME from homeassistant.const import CONF_API_KEY, CONF_PASSWORD, CONF_USERNAME
@ -29,7 +30,7 @@ from tests.common import MockConfigEntry
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry.""" """Override async_setup_entry."""
with patch( with patch(
"homeassistant.components.hydrawise.async_setup_entry", return_value=True "homeassistant.components.hydrawise.async_setup_entry", return_value=True
@ -42,7 +43,7 @@ def mock_legacy_pydrawise(
user: User, user: User,
controller: Controller, controller: Controller,
zones: list[Zone], zones: list[Zone],
) -> Generator[AsyncMock, None, None]: ) -> Generator[AsyncMock]:
"""Mock LegacyHydrawiseAsync.""" """Mock LegacyHydrawiseAsync."""
with patch( with patch(
"pydrawise.legacy.LegacyHydrawiseAsync", autospec=True "pydrawise.legacy.LegacyHydrawiseAsync", autospec=True
@ -61,7 +62,7 @@ def mock_pydrawise(
zones: list[Zone], zones: list[Zone],
sensors: list[Sensor], sensors: list[Sensor],
controller_water_use_summary: ControllerWaterUseSummary, controller_water_use_summary: ControllerWaterUseSummary,
) -> Generator[AsyncMock, None, None]: ) -> Generator[AsyncMock]:
"""Mock Hydrawise.""" """Mock Hydrawise."""
with patch("pydrawise.client.Hydrawise", autospec=True) as mock_pydrawise: with patch("pydrawise.client.Hydrawise", autospec=True) as mock_pydrawise:
user.controllers = [controller] user.controllers = [controller]
@ -75,7 +76,7 @@ def mock_pydrawise(
@pytest.fixture @pytest.fixture
def mock_auth() -> Generator[AsyncMock, None, None]: def mock_auth() -> Generator[AsyncMock]:
"""Mock pydrawise Auth.""" """Mock pydrawise Auth."""
with patch("pydrawise.auth.Auth", autospec=True) as mock_auth: with patch("pydrawise.auth.Auth", autospec=True) as mock_auth:
yield mock_auth.return_value yield mock_auth.return_value

View File

@ -1,14 +1,15 @@
"""IKEA Idasen Desk fixtures.""" """IKEA Idasen Desk fixtures."""
from collections.abc import Callable, Generator from collections.abc import Callable
from unittest import mock from unittest import mock
from unittest.mock import AsyncMock, MagicMock from unittest.mock import AsyncMock, MagicMock
import pytest import pytest
from typing_extensions import Generator
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def mock_bluetooth(enable_bluetooth: None) -> Generator[None, None, None]: def mock_bluetooth(enable_bluetooth: None) -> Generator[None]:
"""Auto mock bluetooth.""" """Auto mock bluetooth."""
with mock.patch( with mock.patch(
"homeassistant.components.idasen_desk.bluetooth.async_ble_device_from_address" "homeassistant.components.idasen_desk.bluetooth.async_ble_device_from_address"

View File

@ -1,8 +1,7 @@
"""Test helpers for image.""" """Test helpers for image."""
from collections.abc import Generator
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components import image from homeassistant.components import image
from homeassistant.config_entries import ConfigEntry, ConfigFlow from homeassistant.config_entries import ConfigEntry, ConfigFlow
@ -125,7 +124,7 @@ class MockImagePlatform:
@pytest.fixture(name="config_flow") @pytest.fixture(name="config_flow")
def config_flow_fixture(hass: HomeAssistant) -> Generator[None, None, None]: def config_flow_fixture(hass: HomeAssistant) -> Generator[None]:
"""Mock config flow.""" """Mock config flow."""
class MockFlow(ConfigFlow): class MockFlow(ConfigFlow):

View File

@ -1,16 +1,16 @@
"""Fixtures for imap tests.""" """Fixtures for imap tests."""
from collections.abc import AsyncGenerator, Generator
from unittest.mock import AsyncMock, MagicMock, patch from unittest.mock import AsyncMock, MagicMock, patch
from aioimaplib import AUTH, LOGOUT, NONAUTH, SELECTED, STARTED, Response from aioimaplib import AUTH, LOGOUT, NONAUTH, SELECTED, STARTED, Response
import pytest import pytest
from typing_extensions import AsyncGenerator, Generator
from .const import EMPTY_SEARCH_RESPONSE, TEST_FETCH_RESPONSE_TEXT_PLAIN from .const import EMPTY_SEARCH_RESPONSE, TEST_FETCH_RESPONSE_TEXT_PLAIN
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry.""" """Override async_setup_entry."""
with patch( with patch(
"homeassistant.components.imap.async_setup_entry", return_value=True "homeassistant.components.imap.async_setup_entry", return_value=True
@ -62,7 +62,7 @@ async def mock_imap_protocol(
imap_pending_idle: bool, imap_pending_idle: bool,
imap_login_state: str, imap_login_state: str,
imap_select_state: str, imap_select_state: str,
) -> AsyncGenerator[MagicMock, None]: ) -> AsyncGenerator[MagicMock]:
"""Mock the aioimaplib IMAP protocol handler.""" """Mock the aioimaplib IMAP protocol handler."""
with patch( with patch(

View File

@ -1,11 +1,11 @@
"""Common fixtures for the IMGW-PIB tests.""" """Common fixtures for the IMGW-PIB tests."""
from collections.abc import Generator
from datetime import UTC, datetime from datetime import UTC, datetime
from unittest.mock import AsyncMock, patch from unittest.mock import AsyncMock, patch
from imgw_pib import HydrologicalData, SensorData from imgw_pib import HydrologicalData, SensorData
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.imgw_pib.const import DOMAIN from homeassistant.components.imgw_pib.const import DOMAIN
@ -27,7 +27,7 @@ HYDROLOGICAL_DATA = HydrologicalData(
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry.""" """Override async_setup_entry."""
with patch( with patch(
"homeassistant.components.imgw_pib.async_setup_entry", return_value=True "homeassistant.components.imgw_pib.async_setup_entry", return_value=True
@ -36,7 +36,7 @@ def mock_setup_entry() -> Generator[AsyncMock, None, None]:
@pytest.fixture @pytest.fixture
def mock_imgw_pib_client() -> Generator[AsyncMock, None, None]: def mock_imgw_pib_client() -> Generator[AsyncMock]:
"""Mock a ImgwPib client.""" """Mock a ImgwPib client."""
with ( with (
patch( patch(

View File

@ -1,10 +1,10 @@
"""Fixtures for Intergas InComfort integration.""" """Fixtures for Intergas InComfort integration."""
from collections.abc import Generator
from typing import Any from typing import Any
from unittest.mock import AsyncMock, MagicMock, patch from unittest.mock import AsyncMock, MagicMock, patch
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.incomfort import DOMAIN from homeassistant.components.incomfort import DOMAIN
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
@ -20,7 +20,7 @@ MOCK_CONFIG = {
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry.""" """Override async_setup_entry."""
with patch( with patch(
"homeassistant.components.incomfort.async_setup_entry", "homeassistant.components.incomfort.async_setup_entry",

View File

@ -1,6 +1,5 @@
"""The tests for the InfluxDB component.""" """The tests for the InfluxDB component."""
from collections.abc import Generator
from dataclasses import dataclass from dataclasses import dataclass
import datetime import datetime
from http import HTTPStatus from http import HTTPStatus
@ -8,6 +7,7 @@ import logging
from unittest.mock import ANY, MagicMock, Mock, call, patch from unittest.mock import ANY, MagicMock, Mock, call, patch
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components import influxdb from homeassistant.components import influxdb
from homeassistant.components.influxdb.const import DEFAULT_BUCKET from homeassistant.components.influxdb.const import DEFAULT_BUCKET
@ -54,7 +54,7 @@ def mock_batch_timeout(hass, monkeypatch):
@pytest.fixture(name="mock_client") @pytest.fixture(name="mock_client")
def mock_client_fixture( def mock_client_fixture(
request: pytest.FixtureRequest, request: pytest.FixtureRequest,
) -> Generator[MagicMock, None, None]: ) -> Generator[MagicMock]:
"""Patch the InfluxDBClient object with mock for version under test.""" """Patch the InfluxDBClient object with mock for version under test."""
if request.param == influxdb.API_VERSION_2: if request.param == influxdb.API_VERSION_2:
client_target = f"{INFLUX_CLIENT_PATH}V2" client_target = f"{INFLUX_CLIENT_PATH}V2"

View File

@ -2,7 +2,6 @@
from __future__ import annotations from __future__ import annotations
from collections.abc import Generator
from dataclasses import dataclass from dataclasses import dataclass
from datetime import timedelta from datetime import timedelta
from http import HTTPStatus from http import HTTPStatus
@ -11,6 +10,7 @@ from unittest.mock import MagicMock, patch
from influxdb.exceptions import InfluxDBClientError, InfluxDBServerError from influxdb.exceptions import InfluxDBClientError, InfluxDBServerError
from influxdb_client.rest import ApiException from influxdb_client.rest import ApiException
import pytest import pytest
from typing_extensions import Generator
from voluptuous import Invalid from voluptuous import Invalid
from homeassistant.components import sensor from homeassistant.components import sensor
@ -82,7 +82,7 @@ class Table:
@pytest.fixture(name="mock_client") @pytest.fixture(name="mock_client")
def mock_client_fixture( def mock_client_fixture(
request: pytest.FixtureRequest, request: pytest.FixtureRequest,
) -> Generator[MagicMock, None, None]: ) -> Generator[MagicMock]:
"""Patch the InfluxDBClient object with mock for version under test.""" """Patch the InfluxDBClient object with mock for version under test."""
if request.param == API_VERSION_2: if request.param == API_VERSION_2:
client_target = f"{INFLUXDB_CLIENT_PATH}V2" client_target = f"{INFLUXDB_CLIENT_PATH}V2"

View File

@ -1,14 +1,14 @@
"""Fixtures for IntelliFire integration tests.""" """Fixtures for IntelliFire integration tests."""
from collections.abc import Generator
from unittest.mock import AsyncMock, MagicMock, Mock, patch from unittest.mock import AsyncMock, MagicMock, Mock, patch
from aiohttp.client_reqrep import ConnectionKey from aiohttp.client_reqrep import ConnectionKey
import pytest import pytest
from typing_extensions import Generator
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Mock setting up a config entry.""" """Mock setting up a config entry."""
with patch( with patch(
"homeassistant.components.intellifire.async_setup_entry", return_value=True "homeassistant.components.intellifire.async_setup_entry", return_value=True

View File

@ -1,10 +1,10 @@
"""Tests for IPMA config flow.""" """Tests for IPMA config flow."""
from collections.abc import Generator
from unittest.mock import patch from unittest.mock import patch
from pyipma import IPMAException from pyipma import IPMAException
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.ipma.const import DOMAIN from homeassistant.components.ipma.const import DOMAIN
from homeassistant.config_entries import SOURCE_USER from homeassistant.config_entries import SOURCE_USER
@ -16,7 +16,7 @@ from tests.components.ipma import MockLocation
@pytest.fixture(name="ipma_setup", autouse=True) @pytest.fixture(name="ipma_setup", autouse=True)
def ipma_setup_fixture() -> Generator[None, None, None]: def ipma_setup_fixture() -> Generator[None]:
"""Patch ipma setup entry.""" """Patch ipma setup entry."""
with patch("homeassistant.components.ipma.async_setup_entry", return_value=True): with patch("homeassistant.components.ipma.async_setup_entry", return_value=True):
yield yield

View File

@ -1,11 +1,11 @@
"""Fixtures for IPP integration tests.""" """Fixtures for IPP integration tests."""
from collections.abc import Generator
import json import json
from unittest.mock import AsyncMock, MagicMock, patch from unittest.mock import AsyncMock, MagicMock, patch
from pyipp import Printer from pyipp import Printer
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.ipp.const import CONF_BASE_PATH, DOMAIN from homeassistant.components.ipp.const import CONF_BASE_PATH, DOMAIN
from homeassistant.const import ( from homeassistant.const import (
@ -39,7 +39,7 @@ def mock_config_entry() -> MockConfigEntry:
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Mock setting up a config entry.""" """Mock setting up a config entry."""
with patch( with patch(
"homeassistant.components.ipp.async_setup_entry", return_value=True "homeassistant.components.ipp.async_setup_entry", return_value=True

View File

@ -1,13 +1,13 @@
"""Common fixtures for the islamic_prayer_times tests.""" """Common fixtures for the islamic_prayer_times tests."""
from collections.abc import Generator
from unittest.mock import AsyncMock, patch from unittest.mock import AsyncMock, patch
import pytest import pytest
from typing_extensions import Generator
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry.""" """Override async_setup_entry."""
with patch( with patch(
"homeassistant.components.islamic_prayer_times.async_setup_entry", "homeassistant.components.islamic_prayer_times.async_setup_entry",

View File

@ -1,10 +1,10 @@
"""Common fixtures for the ista EcoTrend tests.""" """Common fixtures for the ista EcoTrend tests."""
from collections.abc import Generator
from typing import Any from typing import Any
from unittest.mock import AsyncMock, MagicMock, patch from unittest.mock import AsyncMock, MagicMock, patch
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.ista_ecotrend.const import DOMAIN from homeassistant.components.ista_ecotrend.const import DOMAIN
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
@ -26,7 +26,7 @@ def mock_ista_config_entry() -> MockConfigEntry:
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry.""" """Override async_setup_entry."""
with patch( with patch(
"homeassistant.components.ista_ecotrend.async_setup_entry", return_value=True "homeassistant.components.ista_ecotrend.async_setup_entry", return_value=True
@ -35,7 +35,7 @@ def mock_setup_entry() -> Generator[AsyncMock, None, None]:
@pytest.fixture @pytest.fixture
def mock_ista() -> Generator[MagicMock, None, None]: def mock_ista() -> Generator[MagicMock]:
"""Mock Pyecotrend_ista client.""" """Mock Pyecotrend_ista client."""
with ( with (

View File

@ -2,7 +2,6 @@
from __future__ import annotations from __future__ import annotations
from collections.abc import Generator
from unittest.mock import AsyncMock, MagicMock, create_autospec, patch from unittest.mock import AsyncMock, MagicMock, create_autospec, patch
from jellyfin_apiclient_python import JellyfinClient from jellyfin_apiclient_python import JellyfinClient
@ -10,6 +9,7 @@ from jellyfin_apiclient_python.api import API
from jellyfin_apiclient_python.configuration import Config from jellyfin_apiclient_python.configuration import Config
from jellyfin_apiclient_python.connection_manager import ConnectionManager from jellyfin_apiclient_python.connection_manager import ConnectionManager
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.jellyfin.const import DOMAIN from homeassistant.components.jellyfin.const import DOMAIN
from homeassistant.const import CONF_PASSWORD, CONF_URL, CONF_USERNAME from homeassistant.const import CONF_PASSWORD, CONF_URL, CONF_USERNAME
@ -37,7 +37,7 @@ def mock_config_entry() -> MockConfigEntry:
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Mock setting up a config entry.""" """Mock setting up a config entry."""
with patch( with patch(
"homeassistant.components.jellyfin.async_setup_entry", return_value=True "homeassistant.components.jellyfin.async_setup_entry", return_value=True

View File

@ -1,9 +1,9 @@
"""Common fixtures for the jewish_calendar tests.""" """Common fixtures for the jewish_calendar tests."""
from collections.abc import Generator
from unittest.mock import AsyncMock, patch from unittest.mock import AsyncMock, patch
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.jewish_calendar.const import DEFAULT_NAME, DOMAIN from homeassistant.components.jewish_calendar.const import DEFAULT_NAME, DOMAIN
@ -20,7 +20,7 @@ def mock_config_entry() -> MockConfigEntry:
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry.""" """Override async_setup_entry."""
with patch( with patch(
"homeassistant.components.jewish_calendar.async_setup_entry", return_value=True "homeassistant.components.jewish_calendar.async_setup_entry", return_value=True

View File

@ -1,9 +1,9 @@
"""Fixtures for JVC Projector integration.""" """Fixtures for JVC Projector integration."""
from collections.abc import Generator
from unittest.mock import MagicMock, patch from unittest.mock import MagicMock, patch
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.jvc_projector.const import DOMAIN from homeassistant.components.jvc_projector.const import DOMAIN
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT
@ -17,7 +17,7 @@ from tests.common import MockConfigEntry
@pytest.fixture(name="mock_device") @pytest.fixture(name="mock_device")
def fixture_mock_device( def fixture_mock_device(
request: pytest.FixtureRequest, request: pytest.FixtureRequest,
) -> Generator[MagicMock, None, None]: ) -> Generator[MagicMock]:
"""Return a mocked JVC Projector device.""" """Return a mocked JVC Projector device."""
target = "homeassistant.components.jvc_projector.JvcProjector" target = "homeassistant.components.jvc_projector.JvcProjector"
if hasattr(request, "param"): if hasattr(request, "param"):

View File

@ -1,10 +1,10 @@
"""The tests for the demo button component.""" """The tests for the demo button component."""
from collections.abc import AsyncGenerator
from unittest.mock import patch from unittest.mock import patch
from freezegun.api import FrozenDateTimeFactory from freezegun.api import FrozenDateTimeFactory
import pytest import pytest
from typing_extensions import AsyncGenerator
from homeassistant.components.kitchen_sink import DOMAIN from homeassistant.components.kitchen_sink import DOMAIN
from homeassistant.components.notify import ( from homeassistant.components.notify import (
@ -21,7 +21,7 @@ ENTITY_DIRECT_MESSAGE = "notify.mybox_personal_notifier"
@pytest.fixture @pytest.fixture
async def notify_only() -> AsyncGenerator[None, None]: async def notify_only() -> AsyncGenerator[None]:
"""Enable only the button platform.""" """Enable only the button platform."""
with patch( with patch(
"homeassistant.components.kitchen_sink.COMPONENTS_WITH_DEMO_PLATFORM", "homeassistant.components.kitchen_sink.COMPONENTS_WITH_DEMO_PLATFORM",

View File

@ -1,13 +1,13 @@
"""Define fixtures for kmtronic tests.""" """Define fixtures for kmtronic tests."""
from collections.abc import Generator
from unittest.mock import AsyncMock, patch from unittest.mock import AsyncMock, patch
import pytest import pytest
from typing_extensions import Generator
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry.""" """Override async_setup_entry."""
with patch( with patch(
"homeassistant.components.kmtronic.async_setup_entry", return_value=True "homeassistant.components.kmtronic.async_setup_entry", return_value=True

View File

@ -2,11 +2,11 @@
from __future__ import annotations from __future__ import annotations
from collections.abc import Generator
from unittest.mock import AsyncMock, MagicMock, patch from unittest.mock import AsyncMock, MagicMock, patch
from pykoplenti import MeData, VersionData from pykoplenti import MeData, VersionData
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.kostal_plenticore.coordinator import Plenticore from homeassistant.components.kostal_plenticore.coordinator import Plenticore
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -27,7 +27,7 @@ def mock_config_entry() -> MockConfigEntry:
@pytest.fixture @pytest.fixture
def mock_plenticore() -> Generator[Plenticore, None, None]: def mock_plenticore() -> Generator[Plenticore]:
"""Set up a Plenticore mock with some default values.""" """Set up a Plenticore mock with some default values."""
with patch( with patch(
"homeassistant.components.kostal_plenticore.Plenticore", autospec=True "homeassistant.components.kostal_plenticore.Plenticore", autospec=True

View File

@ -1,10 +1,10 @@
"""Test the Kostal Plenticore Solar Inverter config flow.""" """Test the Kostal Plenticore Solar Inverter config flow."""
from collections.abc import Generator
from unittest.mock import ANY, AsyncMock, MagicMock, patch from unittest.mock import ANY, AsyncMock, MagicMock, patch
from pykoplenti import ApiClient, AuthenticationException, SettingsData from pykoplenti import ApiClient, AuthenticationException, SettingsData
import pytest import pytest
from typing_extensions import Generator
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.components.kostal_plenticore.const import DOMAIN from homeassistant.components.kostal_plenticore.const import DOMAIN
@ -25,7 +25,7 @@ def mock_apiclient() -> ApiClient:
@pytest.fixture @pytest.fixture
def mock_apiclient_class(mock_apiclient) -> Generator[type[ApiClient], None, None]: def mock_apiclient_class(mock_apiclient) -> Generator[type[ApiClient]]:
"""Return a mocked ApiClient class.""" """Return a mocked ApiClient class."""
with patch( with patch(
"homeassistant.components.kostal_plenticore.config_flow.ApiClient", "homeassistant.components.kostal_plenticore.config_flow.ApiClient",

View File

@ -1,10 +1,10 @@
"""Test Kostal Plenticore helper.""" """Test Kostal Plenticore helper."""
from collections.abc import Generator
from unittest.mock import AsyncMock, MagicMock, patch from unittest.mock import AsyncMock, MagicMock, patch
from pykoplenti import ApiClient, ExtendedApiClient, SettingsData from pykoplenti import ApiClient, ExtendedApiClient, SettingsData
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.kostal_plenticore.const import DOMAIN from homeassistant.components.kostal_plenticore.const import DOMAIN
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -14,7 +14,7 @@ from tests.common import MockConfigEntry
@pytest.fixture @pytest.fixture
def mock_apiclient() -> Generator[ApiClient, None, None]: def mock_apiclient() -> Generator[ApiClient]:
"""Return a mocked ApiClient class.""" """Return a mocked ApiClient class."""
with patch( with patch(
"homeassistant.components.kostal_plenticore.coordinator.ExtendedApiClient", "homeassistant.components.kostal_plenticore.coordinator.ExtendedApiClient",

View File

@ -1,11 +1,11 @@
"""Test Kostal Plenticore number.""" """Test Kostal Plenticore number."""
from collections.abc import Generator
from datetime import timedelta from datetime import timedelta
from unittest.mock import patch from unittest.mock import patch
from pykoplenti import ApiClient, SettingsData from pykoplenti import ApiClient, SettingsData
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.number import ( from homeassistant.components.number import (
ATTR_MAX, ATTR_MAX,
@ -23,7 +23,7 @@ from tests.common import MockConfigEntry, async_fire_time_changed
@pytest.fixture @pytest.fixture
def mock_plenticore_client() -> Generator[ApiClient, None, None]: def mock_plenticore_client() -> Generator[ApiClient]:
"""Return a patched ExtendedApiClient.""" """Return a patched ExtendedApiClient."""
with patch( with patch(
"homeassistant.components.kostal_plenticore.coordinator.ExtendedApiClient", "homeassistant.components.kostal_plenticore.coordinator.ExtendedApiClient",

View File

@ -1,13 +1,13 @@
"""Define fixtures for LaCrosse View tests.""" """Define fixtures for LaCrosse View tests."""
from collections.abc import Generator
from unittest.mock import AsyncMock, patch from unittest.mock import AsyncMock, patch
import pytest import pytest
from typing_extensions import Generator
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry.""" """Override async_setup_entry."""
with patch( with patch(
"homeassistant.components.lacrosse_view.async_setup_entry", return_value=True "homeassistant.components.lacrosse_view.async_setup_entry", return_value=True

View File

@ -1,10 +1,10 @@
"""Lamarzocco session fixtures.""" """Lamarzocco session fixtures."""
from collections.abc import Generator
from unittest.mock import MagicMock, patch from unittest.mock import MagicMock, patch
from lmcloud.const import LaMarzoccoModel from lmcloud.const import LaMarzoccoModel
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.lamarzocco.const import CONF_MACHINE, DOMAIN from homeassistant.components.lamarzocco.const import CONF_MACHINE, DOMAIN
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME
@ -59,7 +59,7 @@ def device_fixture() -> LaMarzoccoModel:
@pytest.fixture @pytest.fixture
def mock_lamarzocco( def mock_lamarzocco(
request: pytest.FixtureRequest, device_fixture: LaMarzoccoModel request: pytest.FixtureRequest, device_fixture: LaMarzoccoModel
) -> Generator[MagicMock, None, None]: ) -> Generator[MagicMock]:
"""Return a mocked LM client.""" """Return a mocked LM client."""
model_name = device_fixture model_name = device_fixture

View File

@ -2,12 +2,12 @@
from __future__ import annotations from __future__ import annotations
from collections.abc import Generator
from unittest.mock import AsyncMock, MagicMock, patch from unittest.mock import AsyncMock, MagicMock, patch
from demetriek import CloudDevice, Device from demetriek import CloudDevice, Device
from pydantic import parse_raw_as from pydantic import parse_raw_as
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.application_credentials import ( from homeassistant.components.application_credentials import (
ClientCredential, ClientCredential,
@ -46,7 +46,7 @@ def mock_config_entry() -> MockConfigEntry:
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Mock setting up a config entry.""" """Mock setting up a config entry."""
with patch( with patch(
"homeassistant.components.lametric.async_setup_entry", return_value=True "homeassistant.components.lametric.async_setup_entry", return_value=True
@ -55,7 +55,7 @@ def mock_setup_entry() -> Generator[AsyncMock, None, None]:
@pytest.fixture @pytest.fixture
def mock_lametric_cloud() -> Generator[MagicMock, None, None]: def mock_lametric_cloud() -> Generator[MagicMock]:
"""Return a mocked LaMetric Cloud client.""" """Return a mocked LaMetric Cloud client."""
with patch( with patch(
"homeassistant.components.lametric.config_flow.LaMetricCloud", autospec=True "homeassistant.components.lametric.config_flow.LaMetricCloud", autospec=True
@ -74,7 +74,7 @@ def device_fixture() -> str:
@pytest.fixture @pytest.fixture
def mock_lametric(device_fixture: str) -> Generator[MagicMock, None, None]: def mock_lametric(device_fixture: str) -> Generator[MagicMock]:
"""Return a mocked LaMetric TIME client.""" """Return a mocked LaMetric TIME client."""
with ( with (
patch( patch(

View File

@ -1,13 +1,13 @@
"""Define fixtures for Landis + Gyr Heat Meter tests.""" """Define fixtures for Landis + Gyr Heat Meter tests."""
from collections.abc import Generator
from unittest.mock import AsyncMock, patch from unittest.mock import AsyncMock, patch
import pytest import pytest
from typing_extensions import Generator
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry.""" """Override async_setup_entry."""
with patch( with patch(
"homeassistant.components.landisgyr_heat_meter.async_setup_entry", "homeassistant.components.landisgyr_heat_meter.async_setup_entry",

View File

@ -1,9 +1,9 @@
"""The tests for the lawn mower integration.""" """The tests for the lawn mower integration."""
from collections.abc import Generator
from unittest.mock import MagicMock from unittest.mock import MagicMock
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.lawn_mower import ( from homeassistant.components.lawn_mower import (
DOMAIN as LAWN_MOWER_DOMAIN, DOMAIN as LAWN_MOWER_DOMAIN,
@ -52,7 +52,7 @@ class MockLawnMowerEntity(LawnMowerEntity):
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def config_flow_fixture(hass: HomeAssistant) -> Generator[None, None, None]: def config_flow_fixture(hass: HomeAssistant) -> Generator[None]:
"""Mock config flow.""" """Mock config flow."""
mock_platform(hass, f"{TEST_DOMAIN}.config_flow") mock_platform(hass, f"{TEST_DOMAIN}.config_flow")

View File

@ -2,12 +2,13 @@
from __future__ import annotations from __future__ import annotations
from collections.abc import Awaitable, Callable, Generator from collections.abc import Awaitable, Callable
from http import HTTPStatus from http import HTTPStatus
from aiohttp.client_exceptions import ClientError from aiohttp.client_exceptions import ClientError
from aiopyarr.lidarr_client import LidarrClient from aiopyarr.lidarr_client import LidarrClient
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.lidarr.const import DOMAIN from homeassistant.components.lidarr.const import DOMAIN
from homeassistant.const import ( from homeassistant.const import (
@ -132,7 +133,7 @@ def mock_config_entry(hass: HomeAssistant) -> MockConfigEntry:
async def mock_setup_integration( async def mock_setup_integration(
hass: HomeAssistant, hass: HomeAssistant,
config_entry: MockConfigEntry, config_entry: MockConfigEntry,
) -> Generator[ComponentSetup, None, None]: ) -> Generator[ComponentSetup]:
"""Set up the lidarr integration in Home Assistant.""" """Set up the lidarr integration in Home Assistant."""
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)

View File

@ -1,9 +1,9 @@
"""Common fixtures for the Linear Garage Door tests.""" """Common fixtures for the Linear Garage Door tests."""
from collections.abc import Generator
from unittest.mock import AsyncMock, patch from unittest.mock import AsyncMock, patch
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.linear_garage_door import DOMAIN from homeassistant.components.linear_garage_door import DOMAIN
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
@ -16,7 +16,7 @@ from tests.common import (
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry.""" """Override async_setup_entry."""
with patch( with patch(
"homeassistant.components.linear_garage_door.async_setup_entry", "homeassistant.components.linear_garage_door.async_setup_entry",
@ -26,7 +26,7 @@ def mock_setup_entry() -> Generator[AsyncMock, None, None]:
@pytest.fixture @pytest.fixture
def mock_linear() -> Generator[AsyncMock, None, None]: def mock_linear() -> Generator[AsyncMock]:
"""Mock a Linear Garage Door client.""" """Mock a Linear Garage Door client."""
with ( with (
patch( patch(

View File

@ -1,6 +1,6 @@
"""Fixtures for local calendar.""" """Fixtures for local calendar."""
from collections.abc import Awaitable, Callable, Generator from collections.abc import Awaitable, Callable
from http import HTTPStatus from http import HTTPStatus
from pathlib import Path from pathlib import Path
from typing import Any from typing import Any
@ -9,6 +9,7 @@ import urllib
from aiohttp import ClientWebSocketResponse from aiohttp import ClientWebSocketResponse
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.local_calendar import LocalCalendarStore from homeassistant.components.local_calendar import LocalCalendarStore
from homeassistant.components.local_calendar.const import CONF_CALENDAR_NAME, DOMAIN from homeassistant.components.local_calendar.const import CONF_CALENDAR_NAME, DOMAIN
@ -60,9 +61,7 @@ def mock_store_read_side_effect() -> Any | None:
@pytest.fixture(name="store", autouse=True) @pytest.fixture(name="store", autouse=True)
def mock_store( def mock_store(ics_content: str, store_read_side_effect: Any | None) -> Generator[None]:
ics_content: str, store_read_side_effect: Any | None
) -> Generator[None, None, None]:
"""Test cleanup, remove any media storage persisted during the test.""" """Test cleanup, remove any media storage persisted during the test."""
stores: dict[Path, FakeStore] = {} stores: dict[Path, FakeStore] = {}

View File

@ -1,11 +1,11 @@
"""Common fixtures for the local_todo tests.""" """Common fixtures for the local_todo tests."""
from collections.abc import Generator
from pathlib import Path from pathlib import Path
from typing import Any from typing import Any
from unittest.mock import AsyncMock, Mock, patch from unittest.mock import AsyncMock, Mock, patch
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.local_todo import LocalTodoListStore from homeassistant.components.local_todo import LocalTodoListStore
from homeassistant.components.local_todo.const import ( from homeassistant.components.local_todo.const import (
@ -24,7 +24,7 @@ TEST_ENTITY = "todo.my_tasks"
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry.""" """Override async_setup_entry."""
with patch( with patch(
"homeassistant.components.local_todo.async_setup_entry", return_value=True "homeassistant.components.local_todo.async_setup_entry", return_value=True
@ -72,9 +72,7 @@ def mock_store_read_side_effect() -> Any | None:
@pytest.fixture(name="store", autouse=True) @pytest.fixture(name="store", autouse=True)
def mock_store( def mock_store(ics_content: str, store_read_side_effect: Any | None) -> Generator[None]:
ics_content: str, store_read_side_effect: Any | None
) -> Generator[None, None, None]:
"""Fixture that sets up a fake local storage object.""" """Fixture that sets up a fake local storage object."""
stores: dict[Path, FakeStore] = {} stores: dict[Path, FakeStore] = {}

View File

@ -1,10 +1,10 @@
"""Fixtures for the lock entity platform tests.""" """Fixtures for the lock entity platform tests."""
from collections.abc import Generator
from typing import Any from typing import Any
from unittest.mock import MagicMock from unittest.mock import MagicMock
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.lock import ( from homeassistant.components.lock import (
DOMAIN as LOCK_DOMAIN, DOMAIN as LOCK_DOMAIN,
@ -65,7 +65,7 @@ class MockFlow(ConfigFlow):
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def config_flow_fixture(hass: HomeAssistant) -> Generator[None, None, None]: def config_flow_fixture(hass: HomeAssistant) -> Generator[None]:
"""Mock config flow.""" """Mock config flow."""
mock_platform(hass, f"{TEST_DOMAIN}.config_flow") mock_platform(hass, f"{TEST_DOMAIN}.config_flow")

View File

@ -1,12 +1,12 @@
"""Contains fixtures for Loqed tests.""" """Contains fixtures for Loqed tests."""
from collections.abc import AsyncGenerator
import json import json
from typing import Any from typing import Any
from unittest.mock import AsyncMock, Mock, patch from unittest.mock import AsyncMock, Mock, patch
from loqedAPI import loqed from loqedAPI import loqed
import pytest import pytest
from typing_extensions import AsyncGenerator
from homeassistant.components.loqed import DOMAIN from homeassistant.components.loqed import DOMAIN
from homeassistant.components.loqed.const import CONF_CLOUDHOOK_URL from homeassistant.components.loqed.const import CONF_CLOUDHOOK_URL
@ -81,7 +81,7 @@ def lock_fixture() -> loqed.Lock:
@pytest.fixture(name="integration") @pytest.fixture(name="integration")
async def integration_fixture( async def integration_fixture(
hass: HomeAssistant, config_entry: MockConfigEntry, lock: loqed.Lock hass: HomeAssistant, config_entry: MockConfigEntry, lock: loqed.Lock
) -> AsyncGenerator[MockConfigEntry, None]: ) -> AsyncGenerator[MockConfigEntry]:
"""Set up the loqed integration with a config entry.""" """Set up the loqed integration with a config entry."""
config: dict[str, Any] = {DOMAIN: {CONF_API_TOKEN: ""}} config: dict[str, Any] = {DOMAIN: {CONF_API_TOKEN: ""}}
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)

View File

@ -1,10 +1,10 @@
"""Test the Lovelace Cast platform.""" """Test the Lovelace Cast platform."""
from collections.abc import Generator
from time import time from time import time
from unittest.mock import MagicMock, patch from unittest.mock import MagicMock, patch
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.lovelace import cast as lovelace_cast from homeassistant.components.lovelace import cast as lovelace_cast
from homeassistant.components.media_player import MediaClass from homeassistant.components.media_player import MediaClass
@ -17,7 +17,7 @@ from tests.common import async_mock_service
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def mock_onboarding_done() -> Generator[MagicMock, None, None]: def mock_onboarding_done() -> Generator[MagicMock]:
"""Mock that Home Assistant is currently onboarding. """Mock that Home Assistant is currently onboarding.
Enabled to prevent creating default dashboards during test execution. Enabled to prevent creating default dashboards during test execution.

View File

@ -1,11 +1,11 @@
"""Test the Lovelace initialization.""" """Test the Lovelace initialization."""
from collections.abc import Generator
import time import time
from typing import Any from typing import Any
from unittest.mock import MagicMock, patch from unittest.mock import MagicMock, patch
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components import frontend from homeassistant.components import frontend
from homeassistant.components.lovelace import const, dashboard from homeassistant.components.lovelace import const, dashboard
@ -17,7 +17,7 @@ from tests.typing import WebSocketGenerator
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def mock_onboarding_done() -> Generator[MagicMock, None, None]: def mock_onboarding_done() -> Generator[MagicMock]:
"""Mock that Home Assistant is currently onboarding. """Mock that Home Assistant is currently onboarding.
Enabled to prevent creating default dashboards during test execution. Enabled to prevent creating default dashboards during test execution.

View File

@ -1,10 +1,10 @@
"""Test the Lovelace initialization.""" """Test the Lovelace initialization."""
from collections.abc import Generator
from typing import Any from typing import Any
from unittest.mock import MagicMock, patch from unittest.mock import MagicMock, patch
import pytest import pytest
from typing_extensions import Generator
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
@ -13,7 +13,7 @@ from tests.typing import WebSocketGenerator
@pytest.fixture @pytest.fixture
def mock_onboarding_not_done() -> Generator[MagicMock, None, None]: def mock_onboarding_not_done() -> Generator[MagicMock]:
"""Mock that Home Assistant is currently onboarding.""" """Mock that Home Assistant is currently onboarding."""
with patch( with patch(
"homeassistant.components.onboarding.async_is_onboarded", "homeassistant.components.onboarding.async_is_onboarded",
@ -23,7 +23,7 @@ def mock_onboarding_not_done() -> Generator[MagicMock, None, None]:
@pytest.fixture @pytest.fixture
def mock_onboarding_done() -> Generator[MagicMock, None, None]: def mock_onboarding_done() -> Generator[MagicMock]:
"""Mock that Home Assistant is currently onboarding.""" """Mock that Home Assistant is currently onboarding."""
with patch( with patch(
"homeassistant.components.onboarding.async_is_onboarded", "homeassistant.components.onboarding.async_is_onboarded",
@ -33,7 +33,7 @@ def mock_onboarding_done() -> Generator[MagicMock, None, None]:
@pytest.fixture @pytest.fixture
def mock_add_onboarding_listener() -> Generator[MagicMock, None, None]: def mock_add_onboarding_listener() -> Generator[MagicMock]:
"""Mock that Home Assistant is currently onboarding.""" """Mock that Home Assistant is currently onboarding."""
with patch( with patch(
"homeassistant.components.onboarding.async_add_listener", "homeassistant.components.onboarding.async_add_listener",

View File

@ -1,10 +1,10 @@
"""Tests for Lovelace system health.""" """Tests for Lovelace system health."""
from collections.abc import Generator
from typing import Any from typing import Any
from unittest.mock import MagicMock, patch from unittest.mock import MagicMock, patch
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.lovelace import dashboard from homeassistant.components.lovelace import dashboard
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -14,7 +14,7 @@ from tests.common import get_system_health_info
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def mock_onboarding_done() -> Generator[MagicMock, None, None]: def mock_onboarding_done() -> Generator[MagicMock]:
"""Mock that Home Assistant is currently onboarding. """Mock that Home Assistant is currently onboarding.
Enabled to prevent creating default dashboards during test execution. Enabled to prevent creating default dashboards during test execution.

View File

@ -2,10 +2,10 @@
from __future__ import annotations from __future__ import annotations
from collections.abc import Generator
from unittest.mock import MagicMock, patch from unittest.mock import MagicMock, patch
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.luftdaten.const import CONF_SENSOR_ID, DOMAIN from homeassistant.components.luftdaten.const import CONF_SENSOR_ID, DOMAIN
from homeassistant.const import CONF_SHOW_ON_MAP from homeassistant.const import CONF_SHOW_ON_MAP
@ -26,7 +26,7 @@ def mock_config_entry() -> MockConfigEntry:
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[None, None, None]: def mock_setup_entry() -> Generator[None]:
"""Mock setting up a config entry.""" """Mock setting up a config entry."""
with patch( with patch(
"homeassistant.components.luftdaten.async_setup_entry", return_value=True "homeassistant.components.luftdaten.async_setup_entry", return_value=True

View File

@ -1,13 +1,13 @@
"""Provide common Lutron fixtures and mocks.""" """Provide common Lutron fixtures and mocks."""
from collections.abc import Generator
from unittest.mock import AsyncMock, patch from unittest.mock import AsyncMock, patch
import pytest import pytest
from typing_extensions import Generator
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry.""" """Override async_setup_entry."""
with patch( with patch(
"homeassistant.components.lutron.async_setup_entry", return_value=True "homeassistant.components.lutron.async_setup_entry", return_value=True

View File

@ -1,10 +1,10 @@
"""Test the Map initialization.""" """Test the Map initialization."""
from collections.abc import Generator
from typing import Any from typing import Any
from unittest.mock import MagicMock, patch from unittest.mock import MagicMock, patch
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.map import DOMAIN from homeassistant.components.map import DOMAIN
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
@ -15,7 +15,7 @@ from tests.common import MockModule, mock_integration
@pytest.fixture @pytest.fixture
def mock_onboarding_not_done() -> Generator[MagicMock, None, None]: def mock_onboarding_not_done() -> Generator[MagicMock]:
"""Mock that Home Assistant is currently onboarding.""" """Mock that Home Assistant is currently onboarding."""
with patch( with patch(
"homeassistant.components.onboarding.async_is_onboarded", "homeassistant.components.onboarding.async_is_onboarded",
@ -25,7 +25,7 @@ def mock_onboarding_not_done() -> Generator[MagicMock, None, None]:
@pytest.fixture @pytest.fixture
def mock_onboarding_done() -> Generator[MagicMock, None, None]: def mock_onboarding_done() -> Generator[MagicMock]:
"""Mock that Home Assistant is currently onboarding.""" """Mock that Home Assistant is currently onboarding."""
with patch( with patch(
"homeassistant.components.onboarding.async_is_onboarded", "homeassistant.components.onboarding.async_is_onboarded",
@ -35,7 +35,7 @@ def mock_onboarding_done() -> Generator[MagicMock, None, None]:
@pytest.fixture @pytest.fixture
def mock_create_map_dashboard() -> Generator[MagicMock, None, None]: def mock_create_map_dashboard() -> Generator[MagicMock]:
"""Mock the create map dashboard function.""" """Mock the create map dashboard function."""
with patch( with patch(
"homeassistant.components.map._create_map_dashboard", "homeassistant.components.map._create_map_dashboard",

View File

@ -3,13 +3,13 @@
from __future__ import annotations from __future__ import annotations
import asyncio import asyncio
from collections.abc import AsyncGenerator, Generator
from unittest.mock import AsyncMock, MagicMock, patch from unittest.mock import AsyncMock, MagicMock, patch
from matter_server.client.models.node import MatterNode from matter_server.client.models.node import MatterNode
from matter_server.common.const import SCHEMA_VERSION from matter_server.common.const import SCHEMA_VERSION
from matter_server.common.models import ServerInfoMessage from matter_server.common.models import ServerInfoMessage
import pytest import pytest
from typing_extensions import AsyncGenerator, Generator
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -22,7 +22,7 @@ MOCK_COMPR_FABRIC_ID = 1234
@pytest.fixture(name="matter_client") @pytest.fixture(name="matter_client")
async def matter_client_fixture() -> AsyncGenerator[MagicMock, None]: async def matter_client_fixture() -> AsyncGenerator[MagicMock]:
"""Fixture for a Matter client.""" """Fixture for a Matter client."""
with patch( with patch(
"homeassistant.components.matter.MatterClient", autospec=True "homeassistant.components.matter.MatterClient", autospec=True
@ -70,7 +70,7 @@ async def integration_fixture(
@pytest.fixture(name="create_backup") @pytest.fixture(name="create_backup")
def create_backup_fixture() -> Generator[AsyncMock, None, None]: def create_backup_fixture() -> Generator[AsyncMock]:
"""Mock Supervisor create backup of add-on.""" """Mock Supervisor create backup of add-on."""
with patch( with patch(
"homeassistant.components.hassio.addon_manager.async_create_backup" "homeassistant.components.hassio.addon_manager.async_create_backup"
@ -79,7 +79,7 @@ def create_backup_fixture() -> Generator[AsyncMock, None, None]:
@pytest.fixture(name="addon_store_info") @pytest.fixture(name="addon_store_info")
def addon_store_info_fixture() -> Generator[AsyncMock, None, None]: def addon_store_info_fixture() -> Generator[AsyncMock]:
"""Mock Supervisor add-on store info.""" """Mock Supervisor add-on store info."""
with patch( with patch(
"homeassistant.components.hassio.addon_manager.async_get_addon_store_info" "homeassistant.components.hassio.addon_manager.async_get_addon_store_info"
@ -94,7 +94,7 @@ def addon_store_info_fixture() -> Generator[AsyncMock, None, None]:
@pytest.fixture(name="addon_info") @pytest.fixture(name="addon_info")
def addon_info_fixture() -> Generator[AsyncMock, None, None]: def addon_info_fixture() -> Generator[AsyncMock]:
"""Mock Supervisor add-on info.""" """Mock Supervisor add-on info."""
with patch( with patch(
"homeassistant.components.hassio.addon_manager.async_get_addon_info", "homeassistant.components.hassio.addon_manager.async_get_addon_info",
@ -158,7 +158,7 @@ def addon_running_fixture(
@pytest.fixture(name="install_addon") @pytest.fixture(name="install_addon")
def install_addon_fixture( def install_addon_fixture(
addon_store_info: AsyncMock, addon_info: AsyncMock addon_store_info: AsyncMock, addon_info: AsyncMock
) -> Generator[AsyncMock, None, None]: ) -> Generator[AsyncMock]:
"""Mock install add-on.""" """Mock install add-on."""
async def install_addon_side_effect(hass: HomeAssistant, slug: str) -> None: async def install_addon_side_effect(hass: HomeAssistant, slug: str) -> None:
@ -181,7 +181,7 @@ def install_addon_fixture(
@pytest.fixture(name="start_addon") @pytest.fixture(name="start_addon")
def start_addon_fixture() -> Generator[AsyncMock, None, None]: def start_addon_fixture() -> Generator[AsyncMock]:
"""Mock start add-on.""" """Mock start add-on."""
with patch( with patch(
"homeassistant.components.hassio.addon_manager.async_start_addon" "homeassistant.components.hassio.addon_manager.async_start_addon"
@ -190,7 +190,7 @@ def start_addon_fixture() -> Generator[AsyncMock, None, None]:
@pytest.fixture(name="stop_addon") @pytest.fixture(name="stop_addon")
def stop_addon_fixture() -> Generator[AsyncMock, None, None]: def stop_addon_fixture() -> Generator[AsyncMock]:
"""Mock stop add-on.""" """Mock stop add-on."""
with patch( with patch(
"homeassistant.components.hassio.addon_manager.async_stop_addon" "homeassistant.components.hassio.addon_manager.async_stop_addon"
@ -199,7 +199,7 @@ def stop_addon_fixture() -> Generator[AsyncMock, None, None]:
@pytest.fixture(name="uninstall_addon") @pytest.fixture(name="uninstall_addon")
def uninstall_addon_fixture() -> Generator[AsyncMock, None, None]: def uninstall_addon_fixture() -> Generator[AsyncMock]:
"""Mock uninstall add-on.""" """Mock uninstall add-on."""
with patch( with patch(
"homeassistant.components.hassio.addon_manager.async_uninstall_addon" "homeassistant.components.hassio.addon_manager.async_uninstall_addon"
@ -208,7 +208,7 @@ def uninstall_addon_fixture() -> Generator[AsyncMock, None, None]:
@pytest.fixture(name="update_addon") @pytest.fixture(name="update_addon")
def update_addon_fixture() -> Generator[AsyncMock, None, None]: def update_addon_fixture() -> Generator[AsyncMock]:
"""Mock update add-on.""" """Mock update add-on."""
with patch( with patch(
"homeassistant.components.hassio.addon_manager.async_update_addon" "homeassistant.components.hassio.addon_manager.async_update_addon"

View File

@ -1,10 +1,10 @@
"""Test Matter binary sensors.""" """Test Matter binary sensors."""
from collections.abc import Generator
from unittest.mock import MagicMock, patch from unittest.mock import MagicMock, patch
from matter_server.client.models.node import MatterNode from matter_server.client.models.node import MatterNode
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.matter.binary_sensor import ( from homeassistant.components.matter.binary_sensor import (
DISCOVERY_SCHEMAS as BINARY_SENSOR_SCHEMAS, DISCOVERY_SCHEMAS as BINARY_SENSOR_SCHEMAS,
@ -21,7 +21,7 @@ from .common import (
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def binary_sensor_platform() -> Generator[None, None, None]: def binary_sensor_platform() -> Generator[None]:
"""Load only the binary sensor platform.""" """Load only the binary sensor platform."""
with patch( with patch(
"homeassistant.components.matter.discovery.DISCOVERY_SCHEMAS", "homeassistant.components.matter.discovery.DISCOVERY_SCHEMAS",

View File

@ -2,13 +2,13 @@
from __future__ import annotations from __future__ import annotations
from collections.abc import Generator
from ipaddress import ip_address from ipaddress import ip_address
from typing import Any from typing import Any
from unittest.mock import DEFAULT, AsyncMock, MagicMock, call, patch from unittest.mock import DEFAULT, AsyncMock, MagicMock, call, patch
from matter_server.client.exceptions import CannotConnect, InvalidServerVersion from matter_server.client.exceptions import CannotConnect, InvalidServerVersion
import pytest import pytest
from typing_extensions import Generator
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.components.hassio import HassioAPIError, HassioServiceInfo from homeassistant.components.hassio import HassioAPIError, HassioServiceInfo
@ -58,7 +58,7 @@ ZEROCONF_INFO_UDP = ZeroconfServiceInfo(
@pytest.fixture(name="setup_entry", autouse=True) @pytest.fixture(name="setup_entry", autouse=True)
def setup_entry_fixture() -> Generator[AsyncMock, None, None]: def setup_entry_fixture() -> Generator[AsyncMock]:
"""Mock entry setup.""" """Mock entry setup."""
with patch( with patch(
"homeassistant.components.matter.async_setup_entry", return_value=True "homeassistant.components.matter.async_setup_entry", return_value=True
@ -67,7 +67,7 @@ def setup_entry_fixture() -> Generator[AsyncMock, None, None]:
@pytest.fixture(name="unload_entry", autouse=True) @pytest.fixture(name="unload_entry", autouse=True)
def unload_entry_fixture() -> Generator[AsyncMock, None, None]: def unload_entry_fixture() -> Generator[AsyncMock]:
"""Mock entry unload.""" """Mock entry unload."""
with patch( with patch(
"homeassistant.components.matter.async_unload_entry", return_value=True "homeassistant.components.matter.async_unload_entry", return_value=True
@ -76,7 +76,7 @@ def unload_entry_fixture() -> Generator[AsyncMock, None, None]:
@pytest.fixture(name="client_connect", autouse=True) @pytest.fixture(name="client_connect", autouse=True)
def client_connect_fixture() -> Generator[AsyncMock, None, None]: def client_connect_fixture() -> Generator[AsyncMock]:
"""Mock server version.""" """Mock server version."""
with patch( with patch(
"homeassistant.components.matter.config_flow.MatterClient.connect" "homeassistant.components.matter.config_flow.MatterClient.connect"
@ -85,7 +85,7 @@ def client_connect_fixture() -> Generator[AsyncMock, None, None]:
@pytest.fixture(name="supervisor") @pytest.fixture(name="supervisor")
def supervisor_fixture() -> Generator[MagicMock, None, None]: def supervisor_fixture() -> Generator[MagicMock]:
"""Mock Supervisor.""" """Mock Supervisor."""
with patch( with patch(
"homeassistant.components.matter.config_flow.is_hassio", return_value=True "homeassistant.components.matter.config_flow.is_hassio", return_value=True
@ -100,9 +100,7 @@ def discovery_info_fixture() -> Any:
@pytest.fixture(name="get_addon_discovery_info", autouse=True) @pytest.fixture(name="get_addon_discovery_info", autouse=True)
def get_addon_discovery_info_fixture( def get_addon_discovery_info_fixture(discovery_info: Any) -> Generator[AsyncMock]:
discovery_info: Any,
) -> Generator[AsyncMock, None, None]:
"""Mock get add-on discovery info.""" """Mock get add-on discovery info."""
with patch( with patch(
"homeassistant.components.hassio.addon_manager.async_get_addon_discovery_info", "homeassistant.components.hassio.addon_manager.async_get_addon_discovery_info",
@ -112,7 +110,7 @@ def get_addon_discovery_info_fixture(
@pytest.fixture(name="addon_setup_time", autouse=True) @pytest.fixture(name="addon_setup_time", autouse=True)
def addon_setup_time_fixture() -> Generator[int, None, None]: def addon_setup_time_fixture() -> Generator[int]:
"""Mock add-on setup sleep time.""" """Mock add-on setup sleep time."""
with patch( with patch(
"homeassistant.components.matter.config_flow.ADDON_SETUP_TIMEOUT", new=0 "homeassistant.components.matter.config_flow.ADDON_SETUP_TIMEOUT", new=0
@ -121,7 +119,7 @@ def addon_setup_time_fixture() -> Generator[int, None, None]:
@pytest.fixture(name="not_onboarded") @pytest.fixture(name="not_onboarded")
def mock_onboarded_fixture() -> Generator[MagicMock, None, None]: def mock_onboarded_fixture() -> Generator[MagicMock]:
"""Mock that Home Assistant is not yet onboarded.""" """Mock that Home Assistant is not yet onboarded."""
with patch( with patch(
"homeassistant.components.matter.config_flow.async_is_onboarded", "homeassistant.components.matter.config_flow.async_is_onboarded",

View File

@ -3,7 +3,6 @@
from __future__ import annotations from __future__ import annotations
import asyncio import asyncio
from collections.abc import Generator
from unittest.mock import AsyncMock, MagicMock, call, patch from unittest.mock import AsyncMock, MagicMock, call, patch
from matter_server.client.exceptions import CannotConnect, InvalidServerVersion from matter_server.client.exceptions import CannotConnect, InvalidServerVersion
@ -12,6 +11,7 @@ from matter_server.common.errors import MatterError
from matter_server.common.helpers.util import dataclass_from_dict from matter_server.common.helpers.util import dataclass_from_dict
from matter_server.common.models import MatterNodeData from matter_server.common.models import MatterNodeData
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.hassio import HassioAPIError from homeassistant.components.hassio import HassioAPIError
from homeassistant.components.matter.const import DOMAIN from homeassistant.components.matter.const import DOMAIN
@ -32,14 +32,14 @@ from tests.typing import WebSocketGenerator
@pytest.fixture(name="connect_timeout") @pytest.fixture(name="connect_timeout")
def connect_timeout_fixture() -> Generator[int, None, None]: def connect_timeout_fixture() -> Generator[int]:
"""Mock the connect timeout.""" """Mock the connect timeout."""
with patch("homeassistant.components.matter.CONNECT_TIMEOUT", new=0) as timeout: with patch("homeassistant.components.matter.CONNECT_TIMEOUT", new=0) as timeout:
yield timeout yield timeout
@pytest.fixture(name="listen_ready_timeout") @pytest.fixture(name="listen_ready_timeout")
def listen_ready_timeout_fixture() -> Generator[int, None, None]: def listen_ready_timeout_fixture() -> Generator[int]:
"""Mock the listen ready timeout.""" """Mock the listen ready timeout."""
with patch( with patch(
"homeassistant.components.matter.LISTEN_READY_TIMEOUT", new=0 "homeassistant.components.matter.LISTEN_READY_TIMEOUT", new=0

View File

@ -1,10 +1,10 @@
"""Common fixtures for the Media Extractor tests.""" """Common fixtures for the Media Extractor tests."""
from collections.abc import Generator
from typing import Any from typing import Any
from unittest.mock import AsyncMock, patch from unittest.mock import AsyncMock, patch
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.media_extractor import DOMAIN from homeassistant.components.media_extractor import DOMAIN
from homeassistant.core import HomeAssistant, ServiceCall from homeassistant.core import HomeAssistant, ServiceCall
@ -57,7 +57,7 @@ def audio_media_extractor_config() -> dict[str, Any]:
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry.""" """Override async_setup_entry."""
with patch( with patch(
"homeassistant.components.media_extractor.async_setup_entry", return_value=True "homeassistant.components.media_extractor.async_setup_entry", return_value=True

View File

@ -1,6 +1,5 @@
"""Test Local Media Source.""" """Test Local Media Source."""
from collections.abc import AsyncGenerator
from http import HTTPStatus from http import HTTPStatus
import io import io
from pathlib import Path from pathlib import Path
@ -8,6 +7,7 @@ from tempfile import TemporaryDirectory
from unittest.mock import patch from unittest.mock import patch
import pytest import pytest
from typing_extensions import AsyncGenerator
from homeassistant.components import media_source, websocket_api from homeassistant.components import media_source, websocket_api
from homeassistant.components.media_source import const from homeassistant.components.media_source import const
@ -20,7 +20,7 @@ from tests.typing import ClientSessionGenerator, WebSocketGenerator
@pytest.fixture @pytest.fixture
async def temp_dir(hass: HomeAssistant) -> AsyncGenerator[str, None]: async def temp_dir(hass: HomeAssistant) -> AsyncGenerator[str]:
"""Return a temp dir.""" """Return a temp dir."""
with TemporaryDirectory() as tmpdirname: with TemporaryDirectory() as tmpdirname:
target_dir = Path(tmpdirname) / "another_subdir" target_dir = Path(tmpdirname) / "another_subdir"

View File

@ -2,12 +2,12 @@
from __future__ import annotations from __future__ import annotations
from collections.abc import Generator
from datetime import UTC, datetime, time, timedelta from datetime import UTC, datetime, time, timedelta
from unittest.mock import AsyncMock, _patch, patch from unittest.mock import AsyncMock, _patch, patch
from melnor_bluetooth.device import Device from melnor_bluetooth.device import Device
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.bluetooth.models import BluetoothServiceInfoBleak from homeassistant.components.bluetooth.models import BluetoothServiceInfoBleak
from homeassistant.components.melnor.const import DOMAIN from homeassistant.components.melnor.const import DOMAIN
@ -245,7 +245,7 @@ def mock_melnor_device():
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Patch async setup entry to return True.""" """Patch async setup entry to return True."""
with patch( with patch(
"homeassistant.components.melnor.async_setup_entry", return_value=True "homeassistant.components.melnor.async_setup_entry", return_value=True

View File

@ -2,11 +2,11 @@
from __future__ import annotations from __future__ import annotations
from collections.abc import Generator
from unittest.mock import AsyncMock, patch from unittest.mock import AsyncMock, patch
import pytest import pytest
from requests_mock import Mocker from requests_mock import Mocker
from typing_extensions import Generator
from homeassistant.components.mjpeg.const import ( from homeassistant.components.mjpeg.const import (
CONF_MJPEG_URL, CONF_MJPEG_URL,
@ -44,7 +44,7 @@ def mock_config_entry() -> MockConfigEntry:
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Mock setting up a config entry.""" """Mock setting up a config entry."""
with patch( with patch(
"homeassistant.components.mjpeg.async_setup_entry", return_value=True "homeassistant.components.mjpeg.async_setup_entry", return_value=True
@ -53,7 +53,7 @@ def mock_setup_entry() -> Generator[AsyncMock, None, None]:
@pytest.fixture @pytest.fixture
def mock_reload_entry() -> Generator[AsyncMock, None, None]: def mock_reload_entry() -> Generator[AsyncMock]:
"""Mock setting up a config entry.""" """Mock setting up a config entry."""
with patch("homeassistant.components.mjpeg.async_reload_entry") as mock_reload: with patch("homeassistant.components.mjpeg.async_reload_entry") as mock_reload:
yield mock_reload yield mock_reload

View File

@ -2,10 +2,10 @@
from __future__ import annotations from __future__ import annotations
from collections.abc import Generator
from unittest.mock import patch from unittest.mock import patch
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.moon.const import DOMAIN from homeassistant.components.moon.const import DOMAIN
@ -22,7 +22,7 @@ def mock_config_entry() -> MockConfigEntry:
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[None, None, None]: def mock_setup_entry() -> Generator[None]:
"""Mock setting up a config entry.""" """Mock setting up a config entry."""
with patch("homeassistant.components.moon.async_setup_entry", return_value=True): with patch("homeassistant.components.moon.async_setup_entry", return_value=True):
yield yield

View File

@ -1,9 +1,9 @@
"""Fixtures for Vogel's MotionMount integration tests.""" """Fixtures for Vogel's MotionMount integration tests."""
from collections.abc import Generator
from unittest.mock import AsyncMock, MagicMock, patch from unittest.mock import AsyncMock, MagicMock, patch
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.motionmount.const import DOMAIN from homeassistant.components.motionmount.const import DOMAIN
from homeassistant.const import CONF_HOST, CONF_PORT from homeassistant.const import CONF_HOST, CONF_PORT
@ -25,7 +25,7 @@ def mock_config_entry() -> MockConfigEntry:
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Mock setting up a config entry.""" """Mock setting up a config entry."""
with patch( with patch(
"homeassistant.components.motionmount.async_setup_entry", return_value=True "homeassistant.components.motionmount.async_setup_entry", return_value=True

View File

@ -1,6 +1,6 @@
"""Test config flow.""" """Test config flow."""
from collections.abc import Generator, Iterator from collections.abc import Iterator
from contextlib import contextmanager from contextlib import contextmanager
from pathlib import Path from pathlib import Path
from ssl import SSLError from ssl import SSLError
@ -9,6 +9,7 @@ from unittest.mock import AsyncMock, MagicMock, patch
from uuid import uuid4 from uuid import uuid4
import pytest import pytest
from typing_extensions import Generator
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries from homeassistant import config_entries
@ -33,7 +34,7 @@ MOCK_CLIENT_KEY = b"## mock key file ##"
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def mock_finish_setup() -> Generator[MagicMock, None, None]: def mock_finish_setup() -> Generator[MagicMock]:
"""Mock out the finish setup method.""" """Mock out the finish setup method."""
with patch( with patch(
"homeassistant.components.mqtt.MQTT.async_connect", return_value=True "homeassistant.components.mqtt.MQTT.async_connect", return_value=True
@ -42,7 +43,7 @@ def mock_finish_setup() -> Generator[MagicMock, None, None]:
@pytest.fixture @pytest.fixture
def mock_client_cert_check_fail() -> Generator[MagicMock, None, None]: def mock_client_cert_check_fail() -> Generator[MagicMock]:
"""Mock the client certificate check.""" """Mock the client certificate check."""
with patch( with patch(
"homeassistant.components.mqtt.config_flow.load_pem_x509_certificate", "homeassistant.components.mqtt.config_flow.load_pem_x509_certificate",
@ -52,7 +53,7 @@ def mock_client_cert_check_fail() -> Generator[MagicMock, None, None]:
@pytest.fixture @pytest.fixture
def mock_client_key_check_fail() -> Generator[MagicMock, None, None]: def mock_client_key_check_fail() -> Generator[MagicMock]:
"""Mock the client key file check.""" """Mock the client key file check."""
with patch( with patch(
"homeassistant.components.mqtt.config_flow.load_pem_private_key", "homeassistant.components.mqtt.config_flow.load_pem_private_key",
@ -62,7 +63,7 @@ def mock_client_key_check_fail() -> Generator[MagicMock, None, None]:
@pytest.fixture @pytest.fixture
def mock_ssl_context() -> Generator[dict[str, MagicMock], None, None]: def mock_ssl_context() -> Generator[dict[str, MagicMock]]:
"""Mock the SSL context used to load the cert chain and to load verify locations.""" """Mock the SSL context used to load the cert chain and to load verify locations."""
with ( with (
patch("homeassistant.components.mqtt.config_flow.SSLContext") as mock_context, patch("homeassistant.components.mqtt.config_flow.SSLContext") as mock_context,
@ -81,7 +82,7 @@ def mock_ssl_context() -> Generator[dict[str, MagicMock], None, None]:
@pytest.fixture @pytest.fixture
def mock_reload_after_entry_update() -> Generator[MagicMock, None, None]: def mock_reload_after_entry_update() -> Generator[MagicMock]:
"""Mock out the reload after updating the entry.""" """Mock out the reload after updating the entry."""
with patch( with patch(
"homeassistant.components.mqtt._async_config_entry_updated" "homeassistant.components.mqtt._async_config_entry_updated"
@ -90,14 +91,14 @@ def mock_reload_after_entry_update() -> Generator[MagicMock, None, None]:
@pytest.fixture @pytest.fixture
def mock_try_connection() -> Generator[MagicMock, None, None]: def mock_try_connection() -> Generator[MagicMock]:
"""Mock the try connection method.""" """Mock the try connection method."""
with patch("homeassistant.components.mqtt.config_flow.try_connection") as mock_try: with patch("homeassistant.components.mqtt.config_flow.try_connection") as mock_try:
yield mock_try yield mock_try
@pytest.fixture @pytest.fixture
def mock_try_connection_success() -> Generator[MqttMockPahoClient, None, None]: def mock_try_connection_success() -> Generator[MqttMockPahoClient]:
"""Mock the try connection method with success.""" """Mock the try connection method with success."""
_mid = 1 _mid = 1
@ -132,7 +133,7 @@ def mock_try_connection_success() -> Generator[MqttMockPahoClient, None, None]:
@pytest.fixture @pytest.fixture
def mock_try_connection_time_out() -> Generator[MagicMock, None, None]: def mock_try_connection_time_out() -> Generator[MagicMock]:
"""Mock the try connection method with a time out.""" """Mock the try connection method with a time out."""
# Patch prevent waiting 5 sec for a timeout # Patch prevent waiting 5 sec for a timeout
@ -149,7 +150,7 @@ def mock_try_connection_time_out() -> Generator[MagicMock, None, None]:
@pytest.fixture @pytest.fixture
def mock_process_uploaded_file( def mock_process_uploaded_file(
tmp_path: Path, mock_temp_dir: str tmp_path: Path, mock_temp_dir: str
) -> Generator[MagicMock, None, None]: ) -> Generator[MagicMock]:
"""Mock upload certificate files.""" """Mock upload certificate files."""
file_id_ca = str(uuid4()) file_id_ca = str(uuid4())
file_id_cert = str(uuid4()) file_id_cert = str(uuid4())

View File

@ -1,11 +1,11 @@
"""The tests for MQTT tag scanner.""" """The tests for MQTT tag scanner."""
from collections.abc import Generator
import copy import copy
import json import json
from unittest.mock import ANY, AsyncMock, patch from unittest.mock import ANY, AsyncMock, patch
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.device_automation import DeviceAutomationType from homeassistant.components.device_automation import DeviceAutomationType
from homeassistant.components.mqtt.const import DOMAIN as MQTT_DOMAIN from homeassistant.components.mqtt.const import DOMAIN as MQTT_DOMAIN
@ -47,7 +47,7 @@ DEFAULT_TAG_SCAN_JSON = (
@pytest.fixture @pytest.fixture
def tag_mock() -> Generator[AsyncMock, None, None]: def tag_mock() -> Generator[AsyncMock]:
"""Fixture to mock tag.""" """Fixture to mock tag."""
with patch("homeassistant.components.tag.async_scan_tag") as mock_tag: with patch("homeassistant.components.tag.async_scan_tag") as mock_tag:
yield mock_tag yield mock_tag

View File

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
from collections.abc import AsyncGenerator, Callable, Generator from collections.abc import Callable
from copy import deepcopy from copy import deepcopy
import json import json
from typing import Any from typing import Any
@ -12,6 +12,7 @@ from mysensors import BaseSyncGateway
from mysensors.persistence import MySensorsJSONDecoder from mysensors.persistence import MySensorsJSONDecoder
from mysensors.sensor import Sensor from mysensors.sensor import Sensor
import pytest import pytest
from typing_extensions import AsyncGenerator, Generator
from homeassistant.components.mqtt import DOMAIN as MQTT_DOMAIN from homeassistant.components.mqtt import DOMAIN as MQTT_DOMAIN
from homeassistant.components.mysensors.config_flow import DEFAULT_BAUD_RATE from homeassistant.components.mysensors.config_flow import DEFAULT_BAUD_RATE
@ -36,7 +37,7 @@ def mock_mqtt_fixture(hass: HomeAssistant) -> None:
@pytest.fixture(name="is_serial_port") @pytest.fixture(name="is_serial_port")
def is_serial_port_fixture() -> Generator[MagicMock, None, None]: def is_serial_port_fixture() -> Generator[MagicMock]:
"""Patch the serial port check.""" """Patch the serial port check."""
with patch("homeassistant.components.mysensors.gateway.cv.isdevice") as is_device: with patch("homeassistant.components.mysensors.gateway.cv.isdevice") as is_device:
is_device.side_effect = lambda device: device is_device.side_effect = lambda device: device
@ -53,7 +54,7 @@ def gateway_nodes_fixture() -> dict[int, Sensor]:
async def serial_transport_fixture( async def serial_transport_fixture(
gateway_nodes: dict[int, Sensor], gateway_nodes: dict[int, Sensor],
is_serial_port: MagicMock, is_serial_port: MagicMock,
) -> AsyncGenerator[dict[int, Sensor], None]: ) -> AsyncGenerator[dict[int, Sensor]]:
"""Mock a serial transport.""" """Mock a serial transport."""
with ( with (
patch( patch(
@ -136,7 +137,7 @@ def config_entry_fixture(serial_entry: MockConfigEntry) -> MockConfigEntry:
@pytest.fixture(name="integration") @pytest.fixture(name="integration")
async def integration_fixture( async def integration_fixture(
hass: HomeAssistant, transport: MagicMock, config_entry: MockConfigEntry hass: HomeAssistant, transport: MagicMock, config_entry: MockConfigEntry
) -> AsyncGenerator[MockConfigEntry, None]: ) -> AsyncGenerator[MockConfigEntry]:
"""Set up the mysensors integration with a config entry.""" """Set up the mysensors integration with a config entry."""
config: dict[str, Any] = {} config: dict[str, Any] = {}
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)

View File

@ -1,9 +1,9 @@
"""Provide common mystrom fixtures and mocks.""" """Provide common mystrom fixtures and mocks."""
from collections.abc import Generator
from unittest.mock import AsyncMock, patch from unittest.mock import AsyncMock, patch
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.mystrom.const import DOMAIN from homeassistant.components.mystrom.const import DOMAIN
from homeassistant.const import CONF_HOST from homeassistant.const import CONF_HOST
@ -16,7 +16,7 @@ DEVICE_MAC = "6001940376EB"
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry.""" """Override async_setup_entry."""
with patch( with patch(
"homeassistant.components.mystrom.async_setup_entry", return_value=True "homeassistant.components.mystrom.async_setup_entry", return_value=True

View File

@ -1,6 +1,5 @@
"""Test helpers for myuplink.""" """Test helpers for myuplink."""
from collections.abc import AsyncGenerator, Generator
import time import time
from typing import Any from typing import Any
from unittest.mock import MagicMock, patch from unittest.mock import MagicMock, patch
@ -8,6 +7,7 @@ from unittest.mock import MagicMock, patch
from myuplink import Device, DevicePoint, System from myuplink import Device, DevicePoint, System
import orjson import orjson
import pytest import pytest
from typing_extensions import AsyncGenerator, Generator
from homeassistant.components.application_credentials import ( from homeassistant.components.application_credentials import (
ClientCredential, ClientCredential,
@ -135,7 +135,7 @@ def mock_myuplink_client(
device_points_fixture, device_points_fixture,
system_fixture, system_fixture,
load_systems_jv_file, load_systems_jv_file,
) -> Generator[MagicMock, None, None]: ) -> Generator[MagicMock]:
"""Mock a myuplink client.""" """Mock a myuplink client."""
with patch( with patch(
@ -182,7 +182,7 @@ async def setup_platform(
hass: HomeAssistant, hass: HomeAssistant,
mock_config_entry: MockConfigEntry, mock_config_entry: MockConfigEntry,
platforms, platforms,
) -> AsyncGenerator[None, None]: ) -> AsyncGenerator[None]:
"""Set up one or all platforms.""" """Set up one or all platforms."""
with patch(f"homeassistant.components.{DOMAIN}.PLATFORMS", platforms): with patch(f"homeassistant.components.{DOMAIN}.PLATFORMS", platforms):

View File

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
from collections.abc import Awaitable, Callable, Generator from collections.abc import Awaitable, Callable
import copy import copy
from dataclasses import dataclass, field from dataclasses import dataclass, field
import time import time
@ -14,13 +14,14 @@ from google_nest_sdm.device_manager import DeviceManager
from google_nest_sdm.event import EventMessage from google_nest_sdm.event import EventMessage
from google_nest_sdm.event_media import CachePolicy from google_nest_sdm.event_media import CachePolicy
from google_nest_sdm.google_nest_subscriber import GoogleNestSubscriber from google_nest_sdm.google_nest_subscriber import GoogleNestSubscriber
from typing_extensions import Generator
from homeassistant.components.application_credentials import ClientCredential from homeassistant.components.application_credentials import ClientCredential
from homeassistant.components.nest import DOMAIN from homeassistant.components.nest import DOMAIN
# Typing helpers # Typing helpers
type PlatformSetup = Callable[[], Awaitable[None]] type PlatformSetup = Callable[[], Awaitable[None]]
type YieldFixture[_T] = Generator[_T, None, None] type YieldFixture[_T] = Generator[_T]
WEB_AUTH_DOMAIN = DOMAIN WEB_AUTH_DOMAIN = DOMAIN
APP_AUTH_DOMAIN = f"{DOMAIN}.installed" APP_AUTH_DOMAIN = f"{DOMAIN}.installed"

View File

@ -3,7 +3,6 @@
from __future__ import annotations from __future__ import annotations
from asyncio import AbstractEventLoop from asyncio import AbstractEventLoop
from collections.abc import Generator
import copy import copy
import shutil import shutil
import time import time
@ -16,6 +15,7 @@ from google_nest_sdm import diagnostics
from google_nest_sdm.auth import AbstractAuth from google_nest_sdm.auth import AbstractAuth
from google_nest_sdm.device_manager import DeviceManager from google_nest_sdm.device_manager import DeviceManager
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.application_credentials import ( from homeassistant.components.application_credentials import (
async_import_client_credential, async_import_client_credential,
@ -298,7 +298,7 @@ async def setup_platform(
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def reset_diagnostics() -> Generator[None, None, None]: def reset_diagnostics() -> Generator[None]:
"""Fixture to reset client library diagnostic counters.""" """Fixture to reset client library diagnostic counters."""
yield yield
diagnostics.reset() diagnostics.reset()

View File

@ -8,7 +8,6 @@ mode (e.g. yaml, ConfigEntry, etc) however some tests override and just run in
relevant modes. relevant modes.
""" """
from collections.abc import Generator
import logging import logging
from typing import Any from typing import Any
from unittest.mock import patch from unittest.mock import patch
@ -20,6 +19,7 @@ from google_nest_sdm.exceptions import (
SubscriberException, SubscriberException,
) )
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.nest import DOMAIN from homeassistant.components.nest import DOMAIN
from homeassistant.config_entries import ConfigEntryState from homeassistant.config_entries import ConfigEntryState
@ -51,7 +51,7 @@ def platforms() -> list[str]:
@pytest.fixture @pytest.fixture
def error_caplog( def error_caplog(
caplog: pytest.LogCaptureFixture, caplog: pytest.LogCaptureFixture,
) -> Generator[pytest.LogCaptureFixture, None, None]: ) -> Generator[pytest.LogCaptureFixture]:
"""Fixture to capture nest init error messages.""" """Fixture to capture nest init error messages."""
with caplog.at_level(logging.ERROR, logger="homeassistant.components.nest"): with caplog.at_level(logging.ERROR, logger="homeassistant.components.nest"):
yield caplog yield caplog
@ -60,7 +60,7 @@ def error_caplog(
@pytest.fixture @pytest.fixture
def warning_caplog( def warning_caplog(
caplog: pytest.LogCaptureFixture, caplog: pytest.LogCaptureFixture,
) -> Generator[pytest.LogCaptureFixture, None, None]: ) -> Generator[pytest.LogCaptureFixture]:
"""Fixture to capture nest init warning messages.""" """Fixture to capture nest init warning messages."""
with caplog.at_level(logging.WARNING, logger="homeassistant.components.nest"): with caplog.at_level(logging.WARNING, logger="homeassistant.components.nest"):
yield caplog yield caplog

View File

@ -4,7 +4,6 @@ These tests simulate recent camera events received by the subscriber exposed
as media in the media source. as media in the media source.
""" """
from collections.abc import Generator
import datetime import datetime
from http import HTTPStatus from http import HTTPStatus
import io import io
@ -16,6 +15,7 @@ import av
from google_nest_sdm.event import EventMessage from google_nest_sdm.event import EventMessage
import numpy as np import numpy as np
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.media_player.errors import BrowseError from homeassistant.components.media_player.errors import BrowseError
from homeassistant.components.media_source import ( from homeassistant.components.media_source import (
@ -1097,7 +1097,7 @@ async def test_multiple_devices(
@pytest.fixture @pytest.fixture
def event_store() -> Generator[None, None, None]: def event_store() -> Generator[None]:
"""Persist changes to event store immediately.""" """Persist changes to event store immediately."""
with patch( with patch(
"homeassistant.components.nest.media_source.STORAGE_SAVE_DELAY_SECONDS", "homeassistant.components.nest.media_source.STORAGE_SAVE_DELAY_SECONDS",

View File

@ -1,9 +1,9 @@
"""Tests for the Network Configuration integration.""" """Tests for the Network Configuration integration."""
from collections.abc import Generator
from unittest.mock import _patch from unittest.mock import _patch
import pytest import pytest
from typing_extensions import Generator
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
@ -14,7 +14,7 @@ def mock_network():
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def override_mock_get_source_ip( def override_mock_get_source_ip(
mock_get_source_ip: _patch, mock_get_source_ip: _patch,
) -> Generator[None, None, None]: ) -> Generator[None]:
"""Override mock of network util's async_get_source_ip.""" """Override mock of network util's async_get_source_ip."""
mock_get_source_ip.stop() mock_get_source_ip.stop()
yield yield

View File

@ -1,9 +1,9 @@
"""Test the NextBus config flow.""" """Test the NextBus config flow."""
from collections.abc import Generator
from unittest.mock import MagicMock, patch from unittest.mock import MagicMock, patch
import pytest import pytest
from typing_extensions import Generator
from homeassistant import config_entries, setup from homeassistant import config_entries, setup
from homeassistant.components.nextbus.const import CONF_AGENCY, CONF_ROUTE, DOMAIN from homeassistant.components.nextbus.const import CONF_AGENCY, CONF_ROUTE, DOMAIN
@ -13,7 +13,7 @@ from homeassistant.data_entry_flow import FlowResultType
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[MagicMock, None, None]: def mock_setup_entry() -> Generator[MagicMock]:
"""Create a mock for the nextbus component setup.""" """Create a mock for the nextbus component setup."""
with patch( with patch(
"homeassistant.components.nextbus.async_setup_entry", "homeassistant.components.nextbus.async_setup_entry",
@ -23,7 +23,7 @@ def mock_setup_entry() -> Generator[MagicMock, None, None]:
@pytest.fixture @pytest.fixture
def mock_nextbus() -> Generator[MagicMock, None, None]: def mock_nextbus() -> Generator[MagicMock]:
"""Create a mock py_nextbus module.""" """Create a mock py_nextbus module."""
with patch("homeassistant.components.nextbus.config_flow.NextBusClient") as client: with patch("homeassistant.components.nextbus.config_flow.NextBusClient") as client:
yield client yield client

View File

@ -1,12 +1,12 @@
"""The tests for the nexbus sensor component.""" """The tests for the nexbus sensor component."""
from collections.abc import Generator
from copy import deepcopy from copy import deepcopy
from unittest.mock import MagicMock, patch from unittest.mock import MagicMock, patch
from urllib.error import HTTPError from urllib.error import HTTPError
from py_nextbus.client import NextBusFormatError, NextBusHTTPError from py_nextbus.client import NextBusFormatError, NextBusHTTPError
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components import sensor from homeassistant.components import sensor
from homeassistant.components.nextbus.const import CONF_AGENCY, CONF_ROUTE, DOMAIN from homeassistant.components.nextbus.const import CONF_AGENCY, CONF_ROUTE, DOMAIN
@ -66,7 +66,7 @@ BASIC_RESULTS = {
@pytest.fixture @pytest.fixture
def mock_nextbus() -> Generator[MagicMock, None, None]: def mock_nextbus() -> Generator[MagicMock]:
"""Create a mock py_nextbus module.""" """Create a mock py_nextbus module."""
with patch("homeassistant.components.nextbus.coordinator.NextBusClient") as client: with patch("homeassistant.components.nextbus.coordinator.NextBusClient") as client:
yield client yield client
@ -75,7 +75,7 @@ def mock_nextbus() -> Generator[MagicMock, None, None]:
@pytest.fixture @pytest.fixture
def mock_nextbus_predictions( def mock_nextbus_predictions(
mock_nextbus: MagicMock, mock_nextbus: MagicMock,
) -> Generator[MagicMock, None, None]: ) -> Generator[MagicMock]:
"""Create a mock of NextBusClient predictions.""" """Create a mock of NextBusClient predictions."""
instance = mock_nextbus.return_value instance = mock_nextbus.return_value
instance.get_predictions_for_multi_stops.return_value = BASIC_RESULTS instance.get_predictions_for_multi_stops.return_value = BASIC_RESULTS

View File

@ -1,9 +1,9 @@
"""Fixtrues for the Nextcloud integration tests.""" """Fixtrues for the Nextcloud integration tests."""
from collections.abc import Generator
from unittest.mock import AsyncMock, Mock, patch from unittest.mock import AsyncMock, Mock, patch
import pytest import pytest
from typing_extensions import Generator
@pytest.fixture @pytest.fixture
@ -15,7 +15,7 @@ def mock_nextcloud_monitor() -> Mock:
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry.""" """Override async_setup_entry."""
with patch( with patch(
"homeassistant.components.nextcloud.async_setup_entry", return_value=True "homeassistant.components.nextcloud.async_setup_entry", return_value=True

View File

@ -1,12 +1,12 @@
"""Test configuration for Nibe Heat Pump.""" """Test configuration for Nibe Heat Pump."""
from collections.abc import Generator
from contextlib import ExitStack from contextlib import ExitStack
from unittest.mock import AsyncMock, Mock, patch from unittest.mock import AsyncMock, Mock, patch
from freezegun.api import FrozenDateTimeFactory from freezegun.api import FrozenDateTimeFactory
from nibe.exceptions import CoilNotFoundException from nibe.exceptions import CoilNotFoundException
import pytest import pytest
from typing_extensions import Generator
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -16,7 +16,7 @@ from tests.common import async_fire_time_changed
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Make sure we never actually run setup.""" """Make sure we never actually run setup."""
with patch( with patch(
"homeassistant.components.nibe_heatpump.async_setup_entry", return_value=True "homeassistant.components.nibe_heatpump.async_setup_entry", return_value=True

View File

@ -1,8 +1,7 @@
"""Fixtures for Notify platform tests.""" """Fixtures for Notify platform tests."""
from collections.abc import Generator
import pytest import pytest
from typing_extensions import Generator
from homeassistant.config_entries import ConfigFlow from homeassistant.config_entries import ConfigFlow
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -15,7 +14,7 @@ class MockFlow(ConfigFlow):
@pytest.fixture @pytest.fixture
def config_flow_fixture(hass: HomeAssistant) -> Generator[None, None, None]: def config_flow_fixture(hass: HomeAssistant) -> Generator[None]:
"""Mock config flow.""" """Mock config flow."""
mock_platform(hass, "test.config_flow") mock_platform(hass, "test.config_flow")

View File

@ -1,6 +1,5 @@
"""Define fixtures for Notion tests.""" """Define fixtures for Notion tests."""
from collections.abc import Generator
import json import json
from unittest.mock import AsyncMock, Mock, patch from unittest.mock import AsyncMock, Mock, patch
@ -9,6 +8,7 @@ from aionotion.listener.models import Listener
from aionotion.sensor.models import Sensor from aionotion.sensor.models import Sensor
from aionotion.user.models import UserPreferences from aionotion.user.models import UserPreferences
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.notion import CONF_REFRESH_TOKEN, CONF_USER_UUID, DOMAIN from homeassistant.components.notion import CONF_REFRESH_TOKEN, CONF_USER_UUID, DOMAIN
from homeassistant.const import CONF_USERNAME from homeassistant.const import CONF_USERNAME
@ -23,7 +23,7 @@ TEST_USER_UUID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]: def mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry.""" """Override async_setup_entry."""
with patch( with patch(
"homeassistant.components.notion.async_setup_entry", return_value=True "homeassistant.components.notion.async_setup_entry", return_value=True

View File

@ -1,10 +1,10 @@
"""The tests for the Number component.""" """The tests for the Number component."""
from collections.abc import Generator
from typing import Any from typing import Any
from unittest.mock import MagicMock from unittest.mock import MagicMock
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.number import ( from homeassistant.components.number import (
ATTR_MAX, ATTR_MAX,
@ -859,7 +859,7 @@ class MockFlow(ConfigFlow):
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def config_flow_fixture(hass: HomeAssistant) -> Generator[None, None, None]: def config_flow_fixture(hass: HomeAssistant) -> Generator[None]:
"""Mock config flow.""" """Mock config flow."""
mock_platform(hass, f"{TEST_DOMAIN}.config_flow") mock_platform(hass, f"{TEST_DOMAIN}.config_flow")