From 53c85a5c9bc5eb37040b6df2ad6d32dc969d41f9 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Fri, 19 Jul 2024 14:46:30 +0200 Subject: [PATCH] Fix test fixture annotations (#122180) --- tests/components/aosmith/test_sensor.py | 2 +- tests/components/aosmith/test_water_heater.py | 2 +- tests/components/ccm15/conftest.py | 4 ++-- tests/components/ccm15/test_climate.py | 5 +++-- tests/components/ccm15/test_diagnostics.py | 5 ++--- tests/components/ccm15/test_init.py | 5 +++-- tests/components/flume/test_init.py | 2 +- tests/components/hunterdouglas_powerview/conftest.py | 4 ++-- tests/components/hunterdouglas_powerview/test_scene.py | 2 +- tests/components/tailwind/conftest.py | 4 ++-- tests/components/tuya/conftest.py | 4 ++-- 11 files changed, 20 insertions(+), 19 deletions(-) diff --git a/tests/components/aosmith/test_sensor.py b/tests/components/aosmith/test_sensor.py index 8e6f179c088..1dc632b5e84 100644 --- a/tests/components/aosmith/test_sensor.py +++ b/tests/components/aosmith/test_sensor.py @@ -14,7 +14,7 @@ from tests.common import MockConfigEntry, snapshot_platform @pytest.fixture(autouse=True) -async def platforms() -> AsyncGenerator[list[str]]: +async def platforms() -> AsyncGenerator[None]: """Return the platforms to be loaded for this test.""" with patch("homeassistant.components.aosmith.PLATFORMS", [Platform.SENSOR]): yield diff --git a/tests/components/aosmith/test_water_heater.py b/tests/components/aosmith/test_water_heater.py index 3cd0de1722a..69ad8004fc2 100644 --- a/tests/components/aosmith/test_water_heater.py +++ b/tests/components/aosmith/test_water_heater.py @@ -29,7 +29,7 @@ from tests.common import MockConfigEntry, snapshot_platform @pytest.fixture(autouse=True) -async def platforms() -> AsyncGenerator[list[str]]: +async def platforms() -> AsyncGenerator[None]: """Return the platforms to be loaded for this test.""" with patch("homeassistant.components.aosmith.PLATFORMS", [Platform.WATER_HEATER]): yield diff --git a/tests/components/ccm15/conftest.py b/tests/components/ccm15/conftest.py index 3bb67e92c51..e393b2679b6 100644 --- a/tests/components/ccm15/conftest.py +++ b/tests/components/ccm15/conftest.py @@ -17,7 +17,7 @@ def mock_setup_entry() -> Generator[AsyncMock]: @pytest.fixture -def ccm15_device() -> Generator[AsyncMock]: +def ccm15_device() -> Generator[None]: """Mock ccm15 device.""" ccm15_devices = { 0: CCM15SlaveDevice(bytes.fromhex("000000b0b8001b")), @@ -32,7 +32,7 @@ def ccm15_device() -> Generator[AsyncMock]: @pytest.fixture -def network_failure_ccm15_device() -> Generator[AsyncMock]: +def network_failure_ccm15_device() -> Generator[None]: """Mock empty set of ccm15 device.""" device_state = CCM15DeviceState(devices={}) with patch( diff --git a/tests/components/ccm15/test_climate.py b/tests/components/ccm15/test_climate.py index 329caafd11c..785cb17c6a9 100644 --- a/tests/components/ccm15/test_climate.py +++ b/tests/components/ccm15/test_climate.py @@ -1,10 +1,11 @@ """Unit test for CCM15 coordinator component.""" from datetime import timedelta -from unittest.mock import AsyncMock, patch +from unittest.mock import patch from ccm15 import CCM15DeviceState from freezegun.api import FrozenDateTimeFactory +import pytest from syrupy.assertion import SnapshotAssertion from homeassistant.components.ccm15.const import DOMAIN @@ -27,11 +28,11 @@ from homeassistant.helpers import entity_registry as er from tests.common import MockConfigEntry, async_fire_time_changed +@pytest.mark.usefixtures("ccm15_device") async def test_climate_state( hass: HomeAssistant, snapshot: SnapshotAssertion, entity_registry: er.EntityRegistry, - ccm15_device: AsyncMock, freezer: FrozenDateTimeFactory, ) -> None: """Test the coordinator.""" diff --git a/tests/components/ccm15/test_diagnostics.py b/tests/components/ccm15/test_diagnostics.py index a433591d86e..f6f0d75c4e3 100644 --- a/tests/components/ccm15/test_diagnostics.py +++ b/tests/components/ccm15/test_diagnostics.py @@ -1,7 +1,6 @@ """Test CCM15 diagnostics.""" -from unittest.mock import AsyncMock - +import pytest from syrupy import SnapshotAssertion from homeassistant.components.ccm15.const import DOMAIN @@ -13,10 +12,10 @@ from tests.components.diagnostics import get_diagnostics_for_config_entry from tests.typing import ClientSessionGenerator +@pytest.mark.usefixtures("ccm15_device") async def test_entry_diagnostics( hass: HomeAssistant, hass_client: ClientSessionGenerator, - ccm15_device: AsyncMock, snapshot: SnapshotAssertion, ) -> None: """Test config entry diagnostics.""" diff --git a/tests/components/ccm15/test_init.py b/tests/components/ccm15/test_init.py index 3069b61f10f..0fb75920ad3 100644 --- a/tests/components/ccm15/test_init.py +++ b/tests/components/ccm15/test_init.py @@ -1,6 +1,6 @@ """Tests for the ccm15 component.""" -from unittest.mock import AsyncMock +import pytest from homeassistant.components.ccm15.const import DOMAIN from homeassistant.config_entries import ConfigEntryState @@ -10,7 +10,8 @@ from homeassistant.core import HomeAssistant from tests.common import MockConfigEntry -async def test_load_unload(hass: HomeAssistant, ccm15_device: AsyncMock) -> None: +@pytest.mark.usefixtures("ccm15_device") +async def test_load_unload(hass: HomeAssistant) -> None: """Test options flow.""" entry = MockConfigEntry( domain=DOMAIN, diff --git a/tests/components/flume/test_init.py b/tests/components/flume/test_init.py index 44a66425949..85c01c1051e 100644 --- a/tests/components/flume/test_init.py +++ b/tests/components/flume/test_init.py @@ -17,7 +17,7 @@ from tests.common import MockConfigEntry @pytest.fixture(autouse=True) -def platforms_fixture() -> Generator[list[str]]: +def platforms_fixture() -> Generator[None]: """Return the platforms to be loaded for this test.""" # Arbitrary platform to ensure notifications are loaded with patch("homeassistant.components.flume.PLATFORMS", [Platform.BINARY_SENSOR]): diff --git a/tests/components/hunterdouglas_powerview/conftest.py b/tests/components/hunterdouglas_powerview/conftest.py index f7adeb111b8..d4433f93dcb 100644 --- a/tests/components/hunterdouglas_powerview/conftest.py +++ b/tests/components/hunterdouglas_powerview/conftest.py @@ -1,7 +1,7 @@ """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, PropertyMock, patch from aiopvapi.resources.shade import ShadePosition import pytest @@ -29,7 +29,7 @@ def mock_hunterdouglas_hub( rooms_json: str, scenes_json: str, shades_json: str, -) -> Generator[MagicMock]: +) -> Generator[None]: """Return a mocked Powerview Hub with all data populated.""" with ( patch( diff --git a/tests/components/hunterdouglas_powerview/test_scene.py b/tests/components/hunterdouglas_powerview/test_scene.py index 9628805d0e8..43074d55470 100644 --- a/tests/components/hunterdouglas_powerview/test_scene.py +++ b/tests/components/hunterdouglas_powerview/test_scene.py @@ -14,10 +14,10 @@ from .const import MOCK_MAC from tests.common import MockConfigEntry +@pytest.mark.usefixtures("mock_hunterdouglas_hub") @pytest.mark.parametrize("api_version", [1, 2, 3]) async def test_scenes( hass: HomeAssistant, - mock_hunterdouglas_hub: None, api_version: int, ) -> None: """Test the scenes.""" diff --git a/tests/components/tailwind/conftest.py b/tests/components/tailwind/conftest.py index ce49926cd2a..ea87c120308 100644 --- a/tests/components/tailwind/conftest.py +++ b/tests/components/tailwind/conftest.py @@ -3,7 +3,7 @@ from __future__ import annotations from collections.abc import Generator -from unittest.mock import AsyncMock, MagicMock, patch +from unittest.mock import MagicMock, patch from gotailwind import TailwindDeviceStatus import pytest @@ -36,7 +36,7 @@ def mock_config_entry() -> MockConfigEntry: @pytest.fixture -def mock_setup_entry() -> Generator[AsyncMock]: +def mock_setup_entry() -> Generator[None]: """Mock setting up a config entry.""" with patch( "homeassistant.components.tailwind.async_setup_entry", return_value=True diff --git a/tests/components/tuya/conftest.py b/tests/components/tuya/conftest.py index 380209fd5ef..4fffb3ae389 100644 --- a/tests/components/tuya/conftest.py +++ b/tests/components/tuya/conftest.py @@ -3,7 +3,7 @@ from __future__ import annotations from collections.abc import Generator -from unittest.mock import AsyncMock, MagicMock, patch +from unittest.mock import MagicMock, patch import pytest @@ -35,7 +35,7 @@ def mock_config_entry() -> MockConfigEntry: @pytest.fixture -def mock_setup_entry() -> Generator[AsyncMock]: +def mock_setup_entry() -> Generator[None]: """Mock setting up a config entry.""" with patch("homeassistant.components.tuya.async_setup_entry", return_value=True): yield -- GitLab