Improve type hints for silent_ssdp_scanner in tests (#121309)

This commit is contained in:
epenet 2024-07-05 16:32:10 +02:00 committed by GitHub
parent bf8cef3337
commit 45ab9cae1a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 7 additions and 5 deletions

View File

@ -36,7 +36,7 @@ def mock_setup_entry() -> Generator[AsyncMock]:
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
async def silent_ssdp_scanner(hass): def silent_ssdp_scanner() -> Generator[None]:
"""Start SSDP component and get Scanner, prevent actual SSDP traffic.""" """Start SSDP component and get Scanner, prevent actual SSDP traffic."""
with ( with (
patch("homeassistant.components.ssdp.Scanner._async_start_ssdp_listeners"), patch("homeassistant.components.ssdp.Scanner._async_start_ssdp_listeners"),

View File

@ -1,7 +1,7 @@
"""Configuration for Sonos tests.""" """Configuration for Sonos tests."""
import asyncio import asyncio
from collections.abc import Callable from collections.abc import Callable, Generator
from copy import copy from copy import copy
from ipaddress import ip_address from ipaddress import ip_address
from unittest.mock import AsyncMock, MagicMock, Mock, patch from unittest.mock import AsyncMock, MagicMock, Mock, patch
@ -271,7 +271,7 @@ def soco_fixture(soco_factory):
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
async def silent_ssdp_scanner(hass): def silent_ssdp_scanner() -> Generator[None]:
"""Start SSDP component and get Scanner, prevent actual SSDP traffic.""" """Start SSDP component and get Scanner, prevent actual SSDP traffic."""
with ( with (
patch("homeassistant.components.ssdp.Scanner._async_start_ssdp_listeners"), patch("homeassistant.components.ssdp.Scanner._async_start_ssdp_listeners"),

View File

@ -2,6 +2,7 @@
from __future__ import annotations from __future__ import annotations
from collections.abc import Generator
import copy import copy
from datetime import datetime from datetime import datetime
import socket import socket
@ -153,7 +154,7 @@ def mock_setup_entry():
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
async def silent_ssdp_scanner(hass): def silent_ssdp_scanner() -> Generator[None]:
"""Start SSDP component and get Scanner, prevent actual SSDP traffic.""" """Start SSDP component and get Scanner, prevent actual SSDP traffic."""
with ( with (
patch("homeassistant.components.ssdp.Scanner._async_start_ssdp_listeners"), patch("homeassistant.components.ssdp.Scanner._async_start_ssdp_listeners"),

View File

@ -1,5 +1,6 @@
"""Test config flow.""" """Test config flow."""
from collections.abc import Generator
from unittest.mock import patch from unittest.mock import patch
from aiomusiccast import MusicCastConnectionException from aiomusiccast import MusicCastConnectionException
@ -17,7 +18,7 @@ from tests.common import MockConfigEntry
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
async def silent_ssdp_scanner(hass): def silent_ssdp_scanner() -> Generator[None]:
"""Start SSDP component and get Scanner, prevent actual SSDP traffic.""" """Start SSDP component and get Scanner, prevent actual SSDP traffic."""
with ( with (
patch("homeassistant.components.ssdp.Scanner._async_start_ssdp_listeners"), patch("homeassistant.components.ssdp.Scanner._async_start_ssdp_listeners"),