diff --git a/tests/components/smlight/conftest.py b/tests/components/smlight/conftest.py index 0338bf4b672..93493daf51d 100644 --- a/tests/components/smlight/conftest.py +++ b/tests/components/smlight/conftest.py @@ -1,13 +1,14 @@ """Common fixtures for the SMLIGHT Zigbee tests.""" -from collections.abc import Generator +from collections.abc import AsyncGenerator, Generator from unittest.mock import AsyncMock, MagicMock, patch from pysmlight.web import Info, Sensors import pytest +from homeassistant.components.smlight import PLATFORMS from homeassistant.components.smlight.const import DOMAIN -from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME +from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME, Platform from homeassistant.core import HomeAssistant from tests.common import MockConfigEntry, load_json_object_fixture @@ -31,6 +32,19 @@ def mock_config_entry() -> MockConfigEntry: ) +@pytest.fixture +def platforms() -> list[Platform]: + """Platforms, which should be loaded during the test.""" + return PLATFORMS + + +@pytest.fixture(autouse=True) +async def mock_patch_platforms(platforms: list[str]) -> AsyncGenerator[None, None]: + """Fixture to set up platforms for tests.""" + with patch(f"homeassistant.components.{DOMAIN}.PLATFORMS", platforms): + yield + + @pytest.fixture def mock_setup_entry() -> Generator[AsyncMock, None, None]: """Override async_setup_entry.""" @@ -64,7 +78,10 @@ def mock_smlight_client(request: pytest.FixtureRequest) -> Generator[MagicMock]: yield api -async def setup_integration(hass: HomeAssistant, mock_config_entry: MockConfigEntry): +async def setup_integration( + hass: HomeAssistant, + mock_config_entry: MockConfigEntry, +) -> MockConfigEntry: """Set up the integration.""" mock_config_entry.add_to_hass(hass) diff --git a/tests/components/smlight/test_sensor.py b/tests/components/smlight/test_sensor.py index 4d16a73a0a7..e1239c99e32 100644 --- a/tests/components/smlight/test_sensor.py +++ b/tests/components/smlight/test_sensor.py @@ -19,9 +19,9 @@ pytestmark = [ @pytest.fixture -def platforms() -> Platform | list[Platform]: +def platforms() -> list[Platform]: """Platforms, which should be loaded during the test.""" - return Platform.SENSOR + return [Platform.SENSOR] @pytest.mark.usefixtures("entity_registry_enabled_by_default")