diff --git a/tests/components/dlna_dmr/conftest.py b/tests/components/dlna_dmr/conftest.py index f470fbabc6fb3648e5542e4eb0481b39fb97917e..21cb2bc0daf5ce70f80d890254fccd324683f781 100644 --- a/tests/components/dlna_dmr/conftest.py +++ b/tests/components/dlna_dmr/conftest.py @@ -2,7 +2,7 @@ from __future__ import annotations -from collections.abc import Iterable +from collections.abc import Generator from socket import AddressFamily # pylint: disable=no-name-in-module from unittest.mock import Mock, create_autospec, patch, seal @@ -32,7 +32,7 @@ NEW_DEVICE_LOCATION = "http://198.51.100.7" + "/dmr_description.xml" @pytest.fixture -def domain_data_mock(hass: HomeAssistant) -> Iterable[Mock]: +def domain_data_mock(hass: HomeAssistant) -> Mock: """Mock the global data used by this component. This includes network clients and library object factories. Mocking it @@ -114,7 +114,7 @@ def config_entry_mock_no_mac() -> MockConfigEntry: @pytest.fixture -def dmr_device_mock(domain_data_mock: Mock) -> Iterable[Mock]: +def dmr_device_mock(domain_data_mock: Mock) -> Generator[Mock]: """Mock the async_upnp_client DMR device, initially connected.""" with patch( "homeassistant.components.dlna_dmr.media_player.DmrDevice", autospec=True @@ -135,7 +135,7 @@ def dmr_device_mock(domain_data_mock: Mock) -> Iterable[Mock]: @pytest.fixture(autouse=True) -def ssdp_scanner_mock() -> Iterable[Mock]: +def ssdp_scanner_mock() -> Generator[Mock]: """Mock the SSDP Scanner.""" with patch("homeassistant.components.ssdp.Scanner", autospec=True) as mock_scanner: reg_callback = mock_scanner.return_value.async_register_callback @@ -144,14 +144,14 @@ def ssdp_scanner_mock() -> Iterable[Mock]: @pytest.fixture(autouse=True) -def ssdp_server_mock() -> Iterable[Mock]: +def ssdp_server_mock() -> Generator[None]: """Mock the SSDP Server.""" with patch("homeassistant.components.ssdp.Server", autospec=True): yield @pytest.fixture(autouse=True) -def async_get_local_ip_mock() -> Iterable[Mock]: +def async_get_local_ip_mock() -> Generator[Mock]: """Mock the async_get_local_ip utility function to prevent network access.""" with patch( "homeassistant.components.dlna_dmr.media_player.async_get_local_ip", diff --git a/tests/components/dlna_dmr/test_config_flow.py b/tests/components/dlna_dmr/test_config_flow.py index a91cd4744d9532ecef52fa0dca75c705aadfcde8..d60a8f17b838b11a8d0599594586b40bf869322e 100644 --- a/tests/components/dlna_dmr/test_config_flow.py +++ b/tests/components/dlna_dmr/test_config_flow.py @@ -2,7 +2,7 @@ from __future__ import annotations -from collections.abc import Iterable +from collections.abc import Generator import dataclasses import logging from unittest.mock import Mock, patch @@ -89,7 +89,7 @@ MOCK_DISCOVERY = ssdp.SsdpServiceInfo( @pytest.fixture(autouse=True) -def mock_get_mac_address() -> Iterable[Mock]: +def mock_get_mac_address() -> Generator[Mock]: """Mock the get_mac_address function to prevent network access and assist tests.""" with patch( "homeassistant.components.dlna_dmr.config_flow.get_mac_address", autospec=True @@ -99,7 +99,7 @@ def mock_get_mac_address() -> Iterable[Mock]: @pytest.fixture(autouse=True) -def mock_setup_entry() -> Iterable[Mock]: +def mock_setup_entry() -> Generator[Mock]: """Mock async_setup_entry.""" with patch( "homeassistant.components.dlna_dmr.async_setup_entry", return_value=True diff --git a/tests/components/dlna_dmr/test_data.py b/tests/components/dlna_dmr/test_data.py index 57652747ffd9fe4391cb0887a5bea78819ce686e..e67a559f934d60f71f55ae69b30ec2837e9b4897 100644 --- a/tests/components/dlna_dmr/test_data.py +++ b/tests/components/dlna_dmr/test_data.py @@ -2,7 +2,7 @@ from __future__ import annotations -from collections.abc import Iterable +from collections.abc import Generator from unittest.mock import ANY, Mock, patch from async_upnp_client.aiohttp import AiohttpNotifyServer @@ -16,7 +16,7 @@ from homeassistant.core import Event, HomeAssistant @pytest.fixture -def aiohttp_notify_servers_mock() -> Iterable[Mock]: +def aiohttp_notify_servers_mock() -> Generator[Mock]: """Construct mock AiohttpNotifyServer on demand, eliminating network use. This fixture provides a list of the constructed servers. diff --git a/tests/components/dlna_dmr/test_media_player.py b/tests/components/dlna_dmr/test_media_player.py index d202994f9881ef257726c1a0840d637512bc03d6..3d8f9da8ed9b7a60dce2eb51e7da054dd9dd5c85 100644 --- a/tests/components/dlna_dmr/test_media_player.py +++ b/tests/components/dlna_dmr/test_media_player.py @@ -3,7 +3,7 @@ from __future__ import annotations import asyncio -from collections.abc import AsyncIterable, Mapping +from collections.abc import AsyncGenerator, Mapping from dataclasses import dataclass from datetime import timedelta from typing import Any @@ -95,7 +95,7 @@ async def mock_entity_id( config_entry_mock: MockConfigEntry, ssdp_scanner_mock: Mock, dmr_device_mock: Mock, -) -> AsyncIterable[str]: +) -> AsyncGenerator[str]: """Fixture to set up a mock DlnaDmrEntity in a connected state. Yields the entity ID. Cleans up the entity after the test is complete. @@ -145,7 +145,7 @@ async def mock_disconnected_entity_id( config_entry_mock: MockConfigEntry, ssdp_scanner_mock: Mock, dmr_device_mock: Mock, -) -> AsyncIterable[str]: +) -> AsyncGenerator[str]: """Fixture to set up a mock DlnaDmrEntity in a disconnected state. Yields the entity ID. Cleans up the entity after the test is complete. diff --git a/tests/components/dlna_dms/conftest.py b/tests/components/dlna_dms/conftest.py index ed05dfa4c76933a69048a22e87ecc665518f8b8f..eb10babf52778828d37aec787b698980628cd99c 100644 --- a/tests/components/dlna_dms/conftest.py +++ b/tests/components/dlna_dms/conftest.py @@ -2,7 +2,7 @@ from __future__ import annotations -from collections.abc import AsyncIterable, Iterable +from collections.abc import AsyncGenerator, Generator from typing import Final, cast from unittest.mock import AsyncMock, MagicMock, Mock, create_autospec, patch, seal @@ -44,7 +44,7 @@ async def setup_media_source(hass: HomeAssistant) -> None: @pytest.fixture -def upnp_factory_mock() -> Iterable[Mock]: +def upnp_factory_mock() -> Generator[Mock]: """Mock the UpnpFactory class to construct DMS-style UPnP devices.""" with patch( "homeassistant.components.dlna_dms.dms.UpnpFactory", @@ -82,7 +82,7 @@ def upnp_factory_mock() -> Iterable[Mock]: @pytest.fixture(autouse=True, scope="module") -def aiohttp_session_requester_mock() -> Iterable[Mock]: +def aiohttp_session_requester_mock() -> Generator[Mock]: """Mock the AiohttpSessionRequester to prevent network use.""" with patch( "homeassistant.components.dlna_dms.dms.AiohttpSessionRequester", autospec=True @@ -109,7 +109,7 @@ def config_entry_mock() -> MockConfigEntry: @pytest.fixture -def dms_device_mock(upnp_factory_mock: Mock) -> Iterable[Mock]: +def dms_device_mock(upnp_factory_mock: Mock) -> Generator[Mock]: """Mock the async_upnp_client DMS device, initially connected.""" with patch( "homeassistant.components.dlna_dms.dms.DmsDevice", autospec=True @@ -130,7 +130,7 @@ def dms_device_mock(upnp_factory_mock: Mock) -> Iterable[Mock]: @pytest.fixture(autouse=True) -def ssdp_scanner_mock() -> Iterable[Mock]: +def ssdp_scanner_mock() -> Generator[Mock]: """Mock the SSDP Scanner.""" with patch("homeassistant.components.ssdp.Scanner", autospec=True) as mock_scanner: reg_callback = mock_scanner.return_value.async_register_callback @@ -139,7 +139,7 @@ def ssdp_scanner_mock() -> Iterable[Mock]: @pytest.fixture(autouse=True) -def ssdp_server_mock() -> Iterable[Mock]: +def ssdp_server_mock() -> Generator[None]: """Mock the SSDP Server.""" with patch("homeassistant.components.ssdp.Server", autospec=True): yield @@ -151,7 +151,7 @@ async def device_source_mock( config_entry_mock: MockConfigEntry, ssdp_scanner_mock: Mock, dms_device_mock: Mock, -) -> AsyncIterable[None]: +) -> AsyncGenerator[None]: """Fixture to set up a DmsDeviceSource in a connected state and cleanup at completion.""" config_entry_mock.add_to_hass(hass) assert await hass.config_entries.async_setup(config_entry_mock.entry_id) diff --git a/tests/components/dlna_dms/test_config_flow.py b/tests/components/dlna_dms/test_config_flow.py index b61b4a42c494dcf2d6a0ff77b29edab86667f8d1..14da36a038171d4211199fc3450a42b1158861e6 100644 --- a/tests/components/dlna_dms/test_config_flow.py +++ b/tests/components/dlna_dms/test_config_flow.py @@ -2,7 +2,7 @@ from __future__ import annotations -from collections.abc import Iterable +from collections.abc import Generator import dataclasses import logging from typing import Final @@ -68,7 +68,7 @@ MOCK_DISCOVERY: Final = ssdp.SsdpServiceInfo( @pytest.fixture(autouse=True) -def mock_setup_entry() -> Iterable[Mock]: +def mock_setup_entry() -> Generator[Mock]: """Avoid setting up the entire integration.""" with patch( "homeassistant.components.dlna_dms.async_setup_entry",