Fix Generator annotations in tests (1) (#119018)

This commit is contained in:
Marc Mueller 2024-06-07 08:43:32 +02:00 committed by GitHub
parent 7195a21126
commit 274cd41d57
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 60 additions and 74 deletions

View file

@ -1,15 +1,15 @@
"""Fixtures for the Android TV integration tests.""" """Fixtures for the Android TV integration tests."""
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 . import patchers from . import patchers
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def adb_device_tcp_fixture() -> Generator[None, patchers.AdbDeviceTcpAsyncFake, None]: def adb_device_tcp_fixture() -> Generator[None]:
"""Patch ADB Device TCP.""" """Patch ADB Device TCP."""
with patch( with patch(
"androidtv.adb_manager.adb_manager_async.AdbDeviceTcpAsync", "androidtv.adb_manager.adb_manager_async.AdbDeviceTcpAsync",
@ -19,7 +19,7 @@ def adb_device_tcp_fixture() -> Generator[None, patchers.AdbDeviceTcpAsyncFake,
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def load_adbkey_fixture() -> Generator[None, str, None]: def load_adbkey_fixture() -> Generator[None]:
"""Patch load_adbkey.""" """Patch load_adbkey."""
with patch( with patch(
"homeassistant.components.androidtv.ADBPythonSync.load_adbkey", "homeassistant.components.androidtv.ADBPythonSync.load_adbkey",
@ -29,7 +29,7 @@ def load_adbkey_fixture() -> Generator[None, str, None]:
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def keygen_fixture() -> Generator[None, Mock, None]: def keygen_fixture() -> Generator[None]:
"""Patch keygen.""" """Patch keygen."""
with patch( with patch(
"homeassistant.components.androidtv.keygen", "homeassistant.components.androidtv.keygen",

View file

@ -33,7 +33,7 @@ def mock_unload_entry() -> Generator[AsyncMock]:
@pytest.fixture @pytest.fixture
def mock_api() -> Generator[None, MagicMock, None]: def mock_api() -> Generator[MagicMock]:
"""Return a mocked AndroidTVRemote.""" """Return a mocked AndroidTVRemote."""
with patch( with patch(
"homeassistant.components.androidtv_remote.helpers.AndroidTVRemote", "homeassistant.components.androidtv_remote.helpers.AndroidTVRemote",

View file

@ -40,7 +40,7 @@ def mock_setup_entry() -> Generator[AsyncMock]:
@pytest.fixture @pytest.fixture
def mock_bsblan(request: pytest.FixtureRequest) -> Generator[None, MagicMock, None]: def mock_bsblan(request: pytest.FixtureRequest) -> Generator[MagicMock]:
"""Return a mocked BSBLAN client.""" """Return a mocked BSBLAN client."""
with ( with (

View file

@ -1,9 +1,9 @@
"""Fixtures for Electricity maps integration tests.""" """Fixtures for Electricity maps 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.co2signal import DOMAIN from homeassistant.components.co2signal import DOMAIN
from homeassistant.const import CONF_API_KEY from homeassistant.const import CONF_API_KEY
@ -15,7 +15,7 @@ from tests.components.co2signal import VALID_RESPONSE
@pytest.fixture(name="electricity_maps") @pytest.fixture(name="electricity_maps")
def mock_electricity_maps() -> Generator[None, MagicMock, None]: def mock_electricity_maps() -> Generator[MagicMock]:
"""Mock the ElectricityMaps client.""" """Mock the ElectricityMaps client."""
with ( with (

View file

@ -51,7 +51,7 @@ def mock_setup_entry() -> Generator[AsyncMock]:
@pytest.fixture @pytest.fixture
def mock_onboarding() -> Generator[None, MagicMock, 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",
@ -61,9 +61,7 @@ def mock_onboarding() -> Generator[None, MagicMock, None]:
@pytest.fixture @pytest.fixture
def mock_elgato( def mock_elgato(device_fixtures: str, state_variant: str) -> Generator[MagicMock]:
device_fixtures: str, state_variant: str
) -> Generator[None, MagicMock, None]:
"""Return a mocked Elgato client.""" """Return a mocked Elgato client."""
with ( with (
patch( patch(

View file

@ -57,7 +57,7 @@ def mock_config_entry() -> MockConfigEntry:
@pytest.fixture @pytest.fixture
def mock_forecast_solar(hass) -> Generator[None, MagicMock, None]: def mock_forecast_solar(hass: HomeAssistant) -> Generator[MagicMock]:
"""Return a mocked Forecast.Solar client. """Return a mocked Forecast.Solar client.
hass fixture included because it sets the time zone. hass fixture included because it sets the time zone.

View file

@ -37,7 +37,7 @@ def mock_setup_entry() -> Generator[AsyncMock]:
@pytest.fixture @pytest.fixture
def mock_geocaching_config_flow() -> Generator[None, MagicMock, None]: def mock_geocaching_config_flow() -> Generator[MagicMock]:
"""Return a mocked Geocaching API client.""" """Return a mocked Geocaching API client."""
mock_status = GeocachingStatus() mock_status = GeocachingStatus()

View file

@ -88,7 +88,7 @@ def mock_empty_config_entry() -> MockConfigEntry:
@pytest.fixture @pytest.fixture
def mock_homeworks() -> Generator[None, MagicMock, None]: def mock_homeworks() -> Generator[MagicMock]:
"""Return a mocked Homeworks client.""" """Return a mocked Homeworks client."""
with ( with (
patch( patch(

View file

@ -17,7 +17,7 @@ def mock_setup_entry() -> Generator[AsyncMock]:
@pytest.fixture @pytest.fixture
def mock_fireplace_finder_none() -> Generator[None, MagicMock, None]: def mock_fireplace_finder_none() -> Generator[MagicMock]:
"""Mock fireplace finder.""" """Mock fireplace finder."""
mock_found_fireplaces = Mock() mock_found_fireplaces = Mock()
mock_found_fireplaces.ips = [] mock_found_fireplaces.ips = []
@ -28,7 +28,7 @@ def mock_fireplace_finder_none() -> Generator[None, MagicMock, None]:
@pytest.fixture @pytest.fixture
def mock_fireplace_finder_single() -> Generator[None, MagicMock, None]: def mock_fireplace_finder_single() -> Generator[MagicMock]:
"""Mock fireplace finder.""" """Mock fireplace finder."""
mock_found_fireplaces = Mock() mock_found_fireplaces = Mock()
mock_found_fireplaces.ips = ["192.168.1.69"] mock_found_fireplaces.ips = ["192.168.1.69"]
@ -39,7 +39,7 @@ def mock_fireplace_finder_single() -> Generator[None, MagicMock, None]:
@pytest.fixture @pytest.fixture
def mock_intellifire_config_flow() -> Generator[None, MagicMock, None]: def mock_intellifire_config_flow() -> Generator[MagicMock]:
"""Return a mocked IntelliFire client.""" """Return a mocked IntelliFire client."""
data_mock = Mock() data_mock = Mock()
data_mock.serial = "12345" data_mock.serial = "12345"

View file

@ -60,9 +60,7 @@ async def mock_printer(
@pytest.fixture @pytest.fixture
def mock_ipp_config_flow( def mock_ipp_config_flow(mock_printer: Printer) -> Generator[MagicMock]:
mock_printer: Printer,
) -> Generator[None, MagicMock, None]:
"""Return a mocked IPP client.""" """Return a mocked IPP client."""
with patch( with patch(
@ -76,7 +74,7 @@ def mock_ipp_config_flow(
@pytest.fixture @pytest.fixture
def mock_ipp( def mock_ipp(
request: pytest.FixtureRequest, mock_printer: Printer request: pytest.FixtureRequest, mock_printer: Printer
) -> Generator[None, MagicMock, None]: ) -> Generator[MagicMock]:
"""Return a mocked IPP client.""" """Return a mocked IPP client."""
with patch( with patch(

View file

@ -46,7 +46,7 @@ def mock_setup_entry() -> Generator[AsyncMock]:
@pytest.fixture @pytest.fixture
def mock_client_device_id() -> Generator[None, MagicMock, None]: def mock_client_device_id() -> Generator[MagicMock]:
"""Mock generating device id.""" """Mock generating device id."""
with patch( with patch(
"homeassistant.components.jellyfin.config_flow._generate_client_device_id" "homeassistant.components.jellyfin.config_flow._generate_client_device_id"
@ -108,7 +108,7 @@ def mock_client(
@pytest.fixture @pytest.fixture
def mock_jellyfin(mock_client: MagicMock) -> Generator[None, MagicMock, None]: def mock_jellyfin(mock_client: MagicMock) -> Generator[MagicMock]:
"""Return a mocked Jellyfin.""" """Return a mocked Jellyfin."""
with patch( with patch(
"homeassistant.components.jellyfin.client_wrapper.Jellyfin", autospec=True "homeassistant.components.jellyfin.client_wrapper.Jellyfin", autospec=True

View file

@ -1,11 +1,11 @@
"""Fixtures for Kaleidescape integration.""" """Fixtures for Kaleidescape integration."""
from collections.abc import Generator
from unittest.mock import AsyncMock, patch from unittest.mock import AsyncMock, patch
from kaleidescape import Dispatcher from kaleidescape import Dispatcher
from kaleidescape.device import Automation, Movie, Power, System from kaleidescape.device import Automation, Movie, Power, System
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.kaleidescape.const import DOMAIN from homeassistant.components.kaleidescape.const import DOMAIN
from homeassistant.const import CONF_HOST from homeassistant.const import CONF_HOST
@ -17,7 +17,7 @@ from tests.common import MockConfigEntry
@pytest.fixture(name="mock_device") @pytest.fixture(name="mock_device")
def fixture_mock_device() -> Generator[None, AsyncMock, None]: def fixture_mock_device() -> Generator[AsyncMock]:
"""Return a mocked Kaleidescape device.""" """Return a mocked Kaleidescape device."""
with patch( with patch(
"homeassistant.components.kaleidescape.KaleidescapeDevice", autospec=True "homeassistant.components.kaleidescape.KaleidescapeDevice", autospec=True

View file

@ -35,7 +35,7 @@ def mock_setup_entry() -> Generator[None]:
@pytest.fixture @pytest.fixture
def mock_luftdaten() -> Generator[None, MagicMock, None]: def mock_luftdaten() -> Generator[MagicMock]:
"""Return a mocked Luftdaten client.""" """Return a mocked Luftdaten client."""
with ( with (
patch( patch(

View file

@ -34,7 +34,7 @@ def mock_setup_entry() -> Generator[AsyncMock]:
@pytest.fixture @pytest.fixture
def mock_motionmount_config_flow() -> Generator[None, MagicMock, None]: def mock_motionmount_config_flow() -> Generator[MagicMock]:
"""Return a mocked MotionMount config flow.""" """Return a mocked MotionMount config flow."""
with patch( with patch(

View file

@ -1,10 +1,10 @@
"""Test fixtures for mqtt component.""" """Test fixtures for mqtt component."""
from collections.abc import Generator
from random import getrandbits from random import getrandbits
from unittest.mock import patch from unittest.mock import patch
import pytest import pytest
from typing_extensions import Generator
from tests.components.light.conftest import mock_light_profiles # noqa: F401 from tests.components.light.conftest import mock_light_profiles # noqa: F401
@ -21,7 +21,7 @@ def temp_dir_prefix() -> str:
@pytest.fixture @pytest.fixture
def mock_temp_dir(temp_dir_prefix: str) -> Generator[None, None, str]: def mock_temp_dir(temp_dir_prefix: str) -> Generator[str]:
"""Mock the certificate temp directory.""" """Mock the certificate temp directory."""
with patch( with patch(
# Patch temp dir name to avoid tests fail running in parallel # Patch temp dir name to avoid tests fail running in parallel

View file

@ -35,7 +35,7 @@ def mock_setup_entry() -> Generator[None]:
@pytest.fixture @pytest.fixture
def mock_open_meteo(request: pytest.FixtureRequest) -> Generator[None, MagicMock, None]: def mock_open_meteo(request: pytest.FixtureRequest) -> Generator[MagicMock]:
"""Return a mocked Open-Meteo client.""" """Return a mocked Open-Meteo client."""
fixture: str = "forecast.json" fixture: str = "forecast.json"
if hasattr(request, "param") and request.param: if hasattr(request, "param") and request.param:

View file

@ -56,7 +56,7 @@ def mock_setup_entry() -> Generator[AsyncMock]:
@pytest.fixture @pytest.fixture
def mock_smile_config_flow() -> Generator[None, MagicMock, None]: def mock_smile_config_flow() -> Generator[MagicMock]:
"""Return a mocked Smile client.""" """Return a mocked Smile client."""
with patch( with patch(
"homeassistant.components.plugwise.config_flow.Smile", "homeassistant.components.plugwise.config_flow.Smile",
@ -71,7 +71,7 @@ def mock_smile_config_flow() -> Generator[None, MagicMock, None]:
@pytest.fixture @pytest.fixture
def mock_smile_adam() -> Generator[None, MagicMock, None]: def mock_smile_adam() -> Generator[MagicMock]:
"""Create a Mock Adam environment for testing exceptions.""" """Create a Mock Adam environment for testing exceptions."""
chosen_env = "adam_multiple_devices_per_zone" chosen_env = "adam_multiple_devices_per_zone"
@ -97,7 +97,7 @@ def mock_smile_adam() -> Generator[None, MagicMock, None]:
@pytest.fixture @pytest.fixture
def mock_smile_adam_2() -> Generator[None, MagicMock, None]: def mock_smile_adam_2() -> Generator[MagicMock]:
"""Create a 2nd Mock Adam environment for testing exceptions.""" """Create a 2nd Mock Adam environment for testing exceptions."""
chosen_env = "m_adam_heating" chosen_env = "m_adam_heating"
@ -123,7 +123,7 @@ def mock_smile_adam_2() -> Generator[None, MagicMock, None]:
@pytest.fixture @pytest.fixture
def mock_smile_adam_3() -> Generator[None, MagicMock, None]: def mock_smile_adam_3() -> Generator[MagicMock]:
"""Create a 3rd Mock Adam environment for testing exceptions.""" """Create a 3rd Mock Adam environment for testing exceptions."""
chosen_env = "m_adam_cooling" chosen_env = "m_adam_cooling"
@ -149,7 +149,7 @@ def mock_smile_adam_3() -> Generator[None, MagicMock, None]:
@pytest.fixture @pytest.fixture
def mock_smile_adam_4() -> Generator[None, MagicMock, None]: def mock_smile_adam_4() -> Generator[MagicMock]:
"""Create a 4th Mock Adam environment for testing exceptions.""" """Create a 4th Mock Adam environment for testing exceptions."""
chosen_env = "m_adam_jip" chosen_env = "m_adam_jip"
@ -175,7 +175,7 @@ def mock_smile_adam_4() -> Generator[None, MagicMock, None]:
@pytest.fixture @pytest.fixture
def mock_smile_anna() -> Generator[None, MagicMock, None]: def mock_smile_anna() -> Generator[MagicMock]:
"""Create a Mock Anna environment for testing exceptions.""" """Create a Mock Anna environment for testing exceptions."""
chosen_env = "anna_heatpump_heating" chosen_env = "anna_heatpump_heating"
with patch( with patch(
@ -200,7 +200,7 @@ def mock_smile_anna() -> Generator[None, MagicMock, None]:
@pytest.fixture @pytest.fixture
def mock_smile_anna_2() -> Generator[None, MagicMock, None]: def mock_smile_anna_2() -> Generator[MagicMock]:
"""Create a 2nd Mock Anna environment for testing exceptions.""" """Create a 2nd Mock Anna environment for testing exceptions."""
chosen_env = "m_anna_heatpump_cooling" chosen_env = "m_anna_heatpump_cooling"
with patch( with patch(
@ -225,7 +225,7 @@ def mock_smile_anna_2() -> Generator[None, MagicMock, None]:
@pytest.fixture @pytest.fixture
def mock_smile_anna_3() -> Generator[None, MagicMock, None]: def mock_smile_anna_3() -> Generator[MagicMock]:
"""Create a 3rd Mock Anna environment for testing exceptions.""" """Create a 3rd Mock Anna environment for testing exceptions."""
chosen_env = "m_anna_heatpump_idle" chosen_env = "m_anna_heatpump_idle"
with patch( with patch(
@ -250,7 +250,7 @@ def mock_smile_anna_3() -> Generator[None, MagicMock, None]:
@pytest.fixture @pytest.fixture
def mock_smile_p1() -> Generator[None, MagicMock, None]: def mock_smile_p1() -> Generator[MagicMock]:
"""Create a Mock P1 DSMR environment for testing exceptions.""" """Create a Mock P1 DSMR environment for testing exceptions."""
chosen_env = "p1v4_442_single" chosen_env = "p1v4_442_single"
with patch( with patch(
@ -275,7 +275,7 @@ def mock_smile_p1() -> Generator[None, MagicMock, None]:
@pytest.fixture @pytest.fixture
def mock_smile_p1_2() -> Generator[None, MagicMock, None]: def mock_smile_p1_2() -> Generator[MagicMock]:
"""Create a Mock P1 3-phase DSMR environment for testing exceptions.""" """Create a Mock P1 3-phase DSMR environment for testing exceptions."""
chosen_env = "p1v4_442_triple" chosen_env = "p1v4_442_triple"
with patch( with patch(
@ -300,7 +300,7 @@ def mock_smile_p1_2() -> Generator[None, MagicMock, None]:
@pytest.fixture @pytest.fixture
def mock_stretch() -> Generator[None, MagicMock, None]: def mock_stretch() -> Generator[MagicMock]:
"""Create a Mock Stretch environment for testing exceptions.""" """Create a Mock Stretch environment for testing exceptions."""
chosen_env = "stretch_v31" chosen_env = "stretch_v31"
with patch( with patch(

View file

@ -37,7 +37,7 @@ def mock_setup_entry() -> Generator[None]:
@pytest.fixture @pytest.fixture
def mock_pure_energie_config_flow( def mock_pure_energie_config_flow(
request: pytest.FixtureRequest, request: pytest.FixtureRequest,
) -> Generator[None, MagicMock, None]: ) -> Generator[MagicMock]:
"""Return a mocked Pure Energie client.""" """Return a mocked Pure Energie client."""
with patch( with patch(
"homeassistant.components.pure_energie.config_flow.GridNet", autospec=True "homeassistant.components.pure_energie.config_flow.GridNet", autospec=True

View file

@ -36,7 +36,7 @@ def mock_setup_entry() -> Generator[AsyncMock]:
@pytest.fixture @pytest.fixture
def mock_pvoutput() -> Generator[None, MagicMock, None]: def mock_pvoutput() -> Generator[MagicMock]:
"""Return a mocked PVOutput client.""" """Return a mocked PVOutput client."""
with ( with (
patch( patch(

View file

@ -33,7 +33,7 @@ def mock_setup_entry() -> Generator[None]:
@pytest.fixture @pytest.fixture
def mock_rdw_config_flow() -> Generator[None, MagicMock, None]: def mock_rdw_config_flow() -> Generator[MagicMock]:
"""Return a mocked RDW client.""" """Return a mocked RDW client."""
with patch( with patch(
"homeassistant.components.rdw.config_flow.RDW", autospec=True "homeassistant.components.rdw.config_flow.RDW", autospec=True
@ -44,7 +44,7 @@ def mock_rdw_config_flow() -> Generator[None, MagicMock, None]:
@pytest.fixture @pytest.fixture
def mock_rdw(request: pytest.FixtureRequest) -> Generator[None, MagicMock, None]: def mock_rdw(request: pytest.FixtureRequest) -> Generator[MagicMock]:
"""Return a mocked WLED client.""" """Return a mocked WLED client."""
fixture: str = "rdw/11ZKZ3.json" fixture: str = "rdw/11ZKZ3.json"
if hasattr(request, "param") and request.param: if hasattr(request, "param") and request.param:

View file

@ -51,9 +51,7 @@ async def mock_device(
@pytest.fixture @pytest.fixture
def mock_roku_config_flow( def mock_roku_config_flow(mock_device: RokuDevice) -> Generator[MagicMock]:
mock_device: RokuDevice,
) -> Generator[None, MagicMock, None]:
"""Return a mocked Roku client.""" """Return a mocked Roku client."""
with patch( with patch(
@ -68,7 +66,7 @@ def mock_roku_config_flow(
@pytest.fixture @pytest.fixture
def mock_roku( def mock_roku(
request: pytest.FixtureRequest, mock_device: RokuDevice request: pytest.FixtureRequest, mock_device: RokuDevice
) -> Generator[None, MagicMock, None]: ) -> Generator[MagicMock]:
"""Return a mocked Roku client.""" """Return a mocked Roku client."""
with patch( with patch(

View file

@ -109,7 +109,7 @@ def mock_setup_entry() -> Generator[None]:
@pytest.fixture @pytest.fixture
def mock_sonarr_config_flow() -> Generator[None, MagicMock, None]: def mock_sonarr_config_flow() -> Generator[MagicMock]:
"""Return a mocked Sonarr client.""" """Return a mocked Sonarr client."""
with patch( with patch(
"homeassistant.components.sonarr.config_flow.SonarrClient", autospec=True "homeassistant.components.sonarr.config_flow.SonarrClient", autospec=True
@ -127,7 +127,7 @@ def mock_sonarr_config_flow() -> Generator[None, MagicMock, None]:
@pytest.fixture @pytest.fixture
def mock_sonarr() -> Generator[None, MagicMock, None]: def mock_sonarr() -> Generator[MagicMock]:
"""Return a mocked Sonarr client.""" """Return a mocked Sonarr client."""
with patch( with patch(
"homeassistant.components.sonarr.SonarrClient", autospec=True "homeassistant.components.sonarr.SonarrClient", autospec=True

View file

@ -2,12 +2,12 @@
from __future__ import annotations from __future__ import annotations
from collections.abc import Generator
import datetime as dt import datetime as dt
from unittest.mock import MagicMock, patch from unittest.mock import MagicMock, patch
from freezegun.api import FrozenDateTimeFactory from freezegun.api import FrozenDateTimeFactory
import pytest import pytest
from typing_extensions import Generator
from homeassistant.components.srp_energy.const import DOMAIN, PHOENIX_TIME_ZONE from homeassistant.components.srp_energy.const import DOMAIN, PHOENIX_TIME_ZONE
from homeassistant.const import CONF_ID from homeassistant.const import CONF_ID
@ -48,7 +48,7 @@ def fixture_mock_config_entry() -> MockConfigEntry:
@pytest.fixture(name="mock_srp_energy") @pytest.fixture(name="mock_srp_energy")
def fixture_mock_srp_energy() -> Generator[None, MagicMock, None]: def fixture_mock_srp_energy() -> Generator[MagicMock]:
"""Return a mocked SrpEnergyClient client.""" """Return a mocked SrpEnergyClient client."""
with patch( with patch(
"homeassistant.components.srp_energy.SrpEnergyClient", autospec=True "homeassistant.components.srp_energy.SrpEnergyClient", autospec=True
@ -60,7 +60,7 @@ def fixture_mock_srp_energy() -> Generator[None, MagicMock, None]:
@pytest.fixture(name="mock_srp_energy_config_flow") @pytest.fixture(name="mock_srp_energy_config_flow")
def fixture_mock_srp_energy_config_flow() -> Generator[None, MagicMock, None]: def fixture_mock_srp_energy_config_flow() -> Generator[MagicMock]:
"""Return a mocked config_flow SrpEnergyClient client.""" """Return a mocked config_flow SrpEnergyClient client."""
with patch( with patch(
"homeassistant.components.srp_energy.config_flow.SrpEnergyClient", autospec=True "homeassistant.components.srp_energy.config_flow.SrpEnergyClient", autospec=True

View file

@ -36,7 +36,7 @@ def mock_setup_entry() -> Generator[AsyncMock]:
@pytest.fixture @pytest.fixture
def mock_tailscale_config_flow() -> Generator[None, MagicMock, None]: def mock_tailscale_config_flow() -> Generator[MagicMock]:
"""Return a mocked Tailscale client.""" """Return a mocked Tailscale client."""
with patch( with patch(
"homeassistant.components.tailscale.config_flow.Tailscale", autospec=True "homeassistant.components.tailscale.config_flow.Tailscale", autospec=True
@ -49,7 +49,7 @@ def mock_tailscale_config_flow() -> Generator[None, MagicMock, None]:
@pytest.fixture @pytest.fixture
def mock_tailscale(request: pytest.FixtureRequest) -> Generator[None, MagicMock, None]: def mock_tailscale(request: pytest.FixtureRequest) -> Generator[MagicMock]:
"""Return a mocked Tailscale client.""" """Return a mocked Tailscale client."""
fixture: str = "tailscale/devices.json" fixture: str = "tailscale/devices.json"
if hasattr(request, "param") and request.param: if hasattr(request, "param") and request.param:

View file

@ -1,10 +1,10 @@
"""Test the Ukraine Alarm config flow.""" """Test the Ukraine Alarm config flow."""
from collections.abc import Generator
from unittest.mock import AsyncMock, patch from unittest.mock import AsyncMock, patch
from aiohttp import ClientConnectionError, ClientError, ClientResponseError, RequestInfo from aiohttp import ClientConnectionError, ClientError, ClientResponseError, RequestInfo
import pytest import pytest
from typing_extensions import Generator
from yarl import URL from yarl import URL
from homeassistant import config_entries from homeassistant import config_entries
@ -41,7 +41,7 @@ REGIONS = {
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def mock_get_regions() -> Generator[None, AsyncMock, None]: def mock_get_regions() -> Generator[AsyncMock]:
"""Mock the get_regions method.""" """Mock the get_regions method."""
with patch( with patch(

View file

@ -38,7 +38,7 @@ def mock_setup_entry() -> Generator[AsyncMock]:
@pytest.fixture @pytest.fixture
def mock_verisure_config_flow() -> Generator[None, MagicMock, None]: def mock_verisure_config_flow() -> Generator[MagicMock]:
"""Return a mocked Tailscale client.""" """Return a mocked Tailscale client."""
with patch( with patch(
"homeassistant.components.verisure.config_flow.Verisure", autospec=True "homeassistant.components.verisure.config_flow.Verisure", autospec=True

View file

@ -2,10 +2,10 @@
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
import pytest import pytest
from typing_extensions import Generator
@pytest.fixture @pytest.fixture
@ -22,9 +22,7 @@ def subprocess_call_return_value() -> int | None:
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def mock_subprocess_call( def mock_subprocess_call(subprocess_call_return_value: int) -> Generator[MagicMock]:
subprocess_call_return_value: int,
) -> Generator[None, None, MagicMock]:
"""Mock magic packet.""" """Mock magic packet."""
with patch("homeassistant.components.wake_on_lan.switch.sp.call") as mock_sp: with patch("homeassistant.components.wake_on_lan.switch.sp.call") as mock_sp:
mock_sp.return_value = subprocess_call_return_value mock_sp.return_value = subprocess_call_return_value

View file

@ -37,9 +37,7 @@ def mock_setup_entry() -> Generator[None]:
@pytest.fixture @pytest.fixture
def mock_zamg_config_flow( def mock_zamg_config_flow(request: pytest.FixtureRequest) -> Generator[MagicMock]:
request: pytest.FixtureRequest,
) -> Generator[None, MagicMock, None]:
"""Return a mocked Zamg client.""" """Return a mocked Zamg client."""
with patch( with patch(
"homeassistant.components.zamg.sensor.ZamgData", autospec=True "homeassistant.components.zamg.sensor.ZamgData", autospec=True
@ -53,7 +51,7 @@ def mock_zamg_config_flow(
@pytest.fixture @pytest.fixture
def mock_zamg(request: pytest.FixtureRequest) -> Generator[None, MagicMock, None]: def mock_zamg(request: pytest.FixtureRequest) -> Generator[MagicMock]:
"""Return a mocked Zamg client.""" """Return a mocked Zamg client."""
with patch( with patch(
@ -72,9 +70,7 @@ def mock_zamg(request: pytest.FixtureRequest) -> Generator[None, MagicMock, None
@pytest.fixture @pytest.fixture
def mock_zamg_coordinator( def mock_zamg_coordinator(request: pytest.FixtureRequest) -> Generator[MagicMock]:
request: pytest.FixtureRequest,
) -> Generator[None, MagicMock, None]:
"""Return a mocked Zamg client.""" """Return a mocked Zamg client."""
with patch( with patch(
@ -93,9 +89,7 @@ def mock_zamg_coordinator(
@pytest.fixture @pytest.fixture
def mock_zamg_stations( def mock_zamg_stations(request: pytest.FixtureRequest) -> Generator[MagicMock]:
request: pytest.FixtureRequest,
) -> Generator[None, MagicMock, None]:
"""Return a mocked Zamg client.""" """Return a mocked Zamg client."""
with patch( with patch(
"homeassistant.components.zamg.config_flow.ZamgData.zamg_stations" "homeassistant.components.zamg.config_flow.ZamgData.zamg_stations"