From a35af9097bb3bdbee925b4a863548e88c9770c4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ab=C3=ADlio=20Costa?= Date: Thu, 4 Dec 2025 17:21:30 +0000 Subject: [PATCH] Remove uneeded async_setup_component from trigger/condition tests (#157873) --- tests/components/__init__.py | 2 -- .../components/alarm_control_panel/test_trigger.py | 7 ------- tests/components/assist_satellite/test_trigger.py | 7 ------- tests/components/binary_sensor/test_trigger.py | 7 ------- tests/components/climate/test_trigger.py | 13 ------------- tests/components/fan/test_trigger.py | 7 ------- tests/components/lawn_mower/test_trigger.py | 7 ------- tests/components/light/test_condition.py | 4 ---- tests/components/light/test_trigger.py | 7 ------- tests/components/media_player/test_trigger.py | 7 ------- tests/components/text/test_trigger.py | 3 --- tests/components/vacuum/test_trigger.py | 7 ------- 12 files changed, 78 deletions(-) diff --git a/tests/components/__init__.py b/tests/components/__init__.py index 2010c3890fa..15d50d342c0 100644 --- a/tests/components/__init__.py +++ b/tests/components/__init__.py @@ -38,8 +38,6 @@ async def target_entities( - included: List of entity_ids meant to be targeted. - excluded: List of entity_ids not meant to be targeted. """ - await async_setup_component(hass, domain, {}) - config_entry = MockConfigEntry(domain="test") config_entry.add_to_hass(hass) diff --git a/tests/components/alarm_control_panel/test_trigger.py b/tests/components/alarm_control_panel/test_trigger.py index 46f9aee7db0..dee7690527b 100644 --- a/tests/components/alarm_control_panel/test_trigger.py +++ b/tests/components/alarm_control_panel/test_trigger.py @@ -11,7 +11,6 @@ from homeassistant.components.alarm_control_panel import ( ) from homeassistant.const import ATTR_LABEL_ID, ATTR_SUPPORTED_FEATURES, CONF_ENTITY_ID from homeassistant.core import HomeAssistant, ServiceCall -from homeassistant.setup import async_setup_component from tests.components import ( StateDescription, @@ -154,8 +153,6 @@ async def test_alarm_control_panel_state_trigger_behavior_any( states: list[StateDescription], ) -> None: """Test that the alarm control panel state trigger fires when any alarm control panel state changes to a specific state.""" - await async_setup_component(hass, "alarm_control_panel", {}) - other_entity_ids = set(target_alarm_control_panels) - {entity_id} # Set all alarm control panels, including the tested one, to the initial state @@ -266,8 +263,6 @@ async def test_alarm_control_panel_state_trigger_behavior_first( states: list[StateDescription], ) -> None: """Test that the alarm control panel state trigger fires when the first alarm control panel changes to a specific state.""" - await async_setup_component(hass, "alarm_control_panel", {}) - other_entity_ids = set(target_alarm_control_panels) - {entity_id} # Set all alarm control panels, including the tested one, to the initial state @@ -377,8 +372,6 @@ async def test_alarm_control_panel_state_trigger_behavior_last( states: list[StateDescription], ) -> None: """Test that the alarm_control_panel state trigger fires when the last alarm_control_panel changes to a specific state.""" - await async_setup_component(hass, "alarm_control_panel", {}) - other_entity_ids = set(target_alarm_control_panels) - {entity_id} # Set all alarm control panels, including the tested one, to the initial state diff --git a/tests/components/assist_satellite/test_trigger.py b/tests/components/assist_satellite/test_trigger.py index c6c50f6f7bd..80d43e2a619 100644 --- a/tests/components/assist_satellite/test_trigger.py +++ b/tests/components/assist_satellite/test_trigger.py @@ -8,7 +8,6 @@ import pytest from homeassistant.components.assist_satellite.entity import AssistSatelliteState from homeassistant.const import ATTR_LABEL_ID, CONF_ENTITY_ID from homeassistant.core import HomeAssistant, ServiceCall -from homeassistant.setup import async_setup_component from tests.components import ( StateDescription, @@ -105,8 +104,6 @@ async def test_assist_satellite_state_trigger_behavior_any( states: list[StateDescription], ) -> None: """Test that the assist satellite state trigger fires when any assist satellite state changes to a specific state.""" - await async_setup_component(hass, "assist_satellite", {}) - other_entity_ids = set(target_assist_satellites) - {entity_id} # Set all assist satellites, including the tested one, to the initial state @@ -174,8 +171,6 @@ async def test_assist_satellite_state_trigger_behavior_first( states: list[StateDescription], ) -> None: """Test that the assist satellite state trigger fires when the first assist satellite changes to a specific state.""" - await async_setup_component(hass, "assist_satellite", {}) - other_entity_ids = set(target_assist_satellites) - {entity_id} # Set all assist satellites, including the tested one, to the initial state @@ -242,8 +237,6 @@ async def test_assist_satellite_state_trigger_behavior_last( states: list[StateDescription], ) -> None: """Test that the assist_satellite state trigger fires when the last assist_satellite changes to a specific state.""" - await async_setup_component(hass, "assist_satellite", {}) - other_entity_ids = set(target_assist_satellites) - {entity_id} # Set all assist satellites, including the tested one, to the initial state diff --git a/tests/components/binary_sensor/test_trigger.py b/tests/components/binary_sensor/test_trigger.py index 511892c3ac3..f68c63da986 100644 --- a/tests/components/binary_sensor/test_trigger.py +++ b/tests/components/binary_sensor/test_trigger.py @@ -13,7 +13,6 @@ from homeassistant.const import ( STATE_ON, ) from homeassistant.core import HomeAssistant, ServiceCall -from homeassistant.setup import async_setup_component from tests.components import ( StateDescription, @@ -101,8 +100,6 @@ async def test_binary_sensor_state_attribute_trigger_behavior_any( states: list[StateDescription], ) -> None: """Test that the binary sensor state trigger fires when any binary sensor state changes to a specific state.""" - await async_setup_component(hass, "binary_sensor", {}) - other_entity_ids = set(target_binary_sensors["included"]) - {entity_id} excluded_entity_ids = set(target_binary_sensors["excluded"]) - {entity_id} @@ -172,8 +169,6 @@ async def test_binary_sensor_state_attribute_trigger_behavior_first( states: list[StateDescription], ) -> None: """Test that the binary sensor state trigger fires when the first binary sensor state changes to a specific state.""" - await async_setup_component(hass, "binary_sensor", {}) - other_entity_ids = set(target_binary_sensors["included"]) - {entity_id} excluded_entity_ids = set(target_binary_sensors["excluded"]) - {entity_id} @@ -242,8 +237,6 @@ async def test_binary_sensor_state_attribute_trigger_behavior_last( states: list[StateDescription], ) -> None: """Test that the binary sensor state trigger fires when the last binary sensor state changes to a specific state.""" - await async_setup_component(hass, "binary_sensor", {}) - other_entity_ids = set(target_binary_sensors["included"]) - {entity_id} excluded_entity_ids = set(target_binary_sensors["excluded"]) - {entity_id} diff --git a/tests/components/climate/test_trigger.py b/tests/components/climate/test_trigger.py index ec6ec640d14..b6245b0e659 100644 --- a/tests/components/climate/test_trigger.py +++ b/tests/components/climate/test_trigger.py @@ -12,7 +12,6 @@ from homeassistant.components.climate.const import ( ) from homeassistant.const import ATTR_LABEL_ID, CONF_ENTITY_ID from homeassistant.core import HomeAssistant, ServiceCall -from homeassistant.setup import async_setup_component from tests.components import ( StateDescription, @@ -107,8 +106,6 @@ async def test_climate_state_trigger_behavior_any( states: list[StateDescription], ) -> None: """Test that the climate state trigger fires when any climate state changes to a specific state.""" - await async_setup_component(hass, "climate", {}) - other_entity_ids = set(target_climates) - {entity_id} # Set all climates, including the tested climate, to the initial state @@ -171,8 +168,6 @@ async def test_climate_state_attribute_trigger_behavior_any( states: list[StateDescription], ) -> None: """Test that the climate state trigger fires when any climate state changes to a specific state.""" - await async_setup_component(hass, "climate", {}) - other_entity_ids = set(target_climates) - {entity_id} # Set all climates, including the tested climate, to the initial state @@ -239,8 +234,6 @@ async def test_climate_state_trigger_behavior_first( states: list[StateDescription], ) -> None: """Test that the climate state trigger fires when the first climate changes to a specific state.""" - await async_setup_component(hass, "climate", {}) - other_entity_ids = set(target_climates) - {entity_id} # Set all climates, including the tested climate, to the initial state @@ -302,8 +295,6 @@ async def test_climate_state_attribute_trigger_behavior_first( states: list[tuple[tuple[str, dict], int]], ) -> None: """Test that the climate state trigger fires when any climate state changes to a specific state.""" - await async_setup_component(hass, "climate", {}) - other_entity_ids = set(target_climates) - {entity_id} # Set all climates, including the tested climate, to the initial state @@ -369,8 +360,6 @@ async def test_climate_state_trigger_behavior_last( states: list[StateDescription], ) -> None: """Test that the climate state trigger fires when the last climate changes to a specific state.""" - await async_setup_component(hass, "climate", {}) - other_entity_ids = set(target_climates) - {entity_id} # Set all climates, including the tested climate, to the initial state @@ -431,8 +420,6 @@ async def test_climate_state_attribute_trigger_behavior_last( states: list[tuple[tuple[str, dict], int]], ) -> None: """Test that the climate state trigger fires when any climate state changes to a specific state.""" - await async_setup_component(hass, "climate", {}) - other_entity_ids = set(target_climates) - {entity_id} # Set all climates, including the tested climate, to the initial state diff --git a/tests/components/fan/test_trigger.py b/tests/components/fan/test_trigger.py index ae456c1d702..ea3b56a35cb 100644 --- a/tests/components/fan/test_trigger.py +++ b/tests/components/fan/test_trigger.py @@ -7,7 +7,6 @@ import pytest from homeassistant.const import ATTR_LABEL_ID, CONF_ENTITY_ID, STATE_OFF, STATE_ON from homeassistant.core import HomeAssistant, ServiceCall -from homeassistant.setup import async_setup_component from tests.components import ( StateDescription, @@ -91,8 +90,6 @@ async def test_fan_state_trigger_behavior_any( states: list[StateDescription], ) -> None: """Test that the fan state trigger fires when any fan state changes to a specific state.""" - await async_setup_component(hass, "fan", {}) - other_entity_ids = set(target_fans) - {entity_id} # Set all fans, including the tested fan, to the initial state @@ -150,8 +147,6 @@ async def test_fan_state_trigger_behavior_first( states: list[StateDescription], ) -> None: """Test that the fan state trigger fires when the first fan changes to a specific state.""" - await async_setup_component(hass, "fan", {}) - other_entity_ids = set(target_fans) - {entity_id} # Set all fans, including the tested fan, to the initial state @@ -208,8 +203,6 @@ async def test_fan_state_trigger_behavior_last( states: list[StateDescription], ) -> None: """Test that the fan state trigger fires when the last fan changes to a specific state.""" - await async_setup_component(hass, "fan", {}) - other_entity_ids = set(target_fans) - {entity_id} # Set all fans, including the tested fan, to the initial state diff --git a/tests/components/lawn_mower/test_trigger.py b/tests/components/lawn_mower/test_trigger.py index dea18c9898a..018d83afbfb 100644 --- a/tests/components/lawn_mower/test_trigger.py +++ b/tests/components/lawn_mower/test_trigger.py @@ -8,7 +8,6 @@ import pytest from homeassistant.components.lawn_mower import LawnMowerActivity from homeassistant.const import ATTR_LABEL_ID, CONF_ENTITY_ID from homeassistant.core import HomeAssistant, ServiceCall -from homeassistant.setup import async_setup_component from tests.components import ( StateDescription, @@ -105,8 +104,6 @@ async def test_lawn_mower_state_trigger_behavior_any( states: list[StateDescription], ) -> None: """Test that the lawn mower state trigger fires when any lawn mower state changes to a specific state.""" - await async_setup_component(hass, "lawn_mower", {}) - other_entity_ids = set(target_lawn_mowers) - {entity_id} # Set all lawn mowers, including the tested one, to the initial state @@ -174,8 +171,6 @@ async def test_lawn_mower_state_trigger_behavior_first( states: list[StateDescription], ) -> None: """Test that the lawn mower state trigger fires when the first lawn mower changes to a specific state.""" - await async_setup_component(hass, "lawn_mower", {}) - other_entity_ids = set(target_lawn_mowers) - {entity_id} # Set all lawn mowers, including the tested one, to the initial state @@ -242,8 +237,6 @@ async def test_lawn_mower_state_trigger_behavior_last( states: list[StateDescription], ) -> None: """Test that the lawn_mower state trigger fires when the last lawn_mower changes to a specific state.""" - await async_setup_component(hass, "lawn_mower", {}) - other_entity_ids = set(target_lawn_mowers) - {entity_id} # Set all lawn mowers, including the tested one, to the initial state diff --git a/tests/components/light/test_condition.py b/tests/components/light/test_condition.py index e8dc138f3e2..8eb9fb4c50c 100644 --- a/tests/components/light/test_condition.py +++ b/tests/components/light/test_condition.py @@ -152,8 +152,6 @@ async def test_light_state_condition_behavior_any( other_state: str, ) -> None: """Test the light state condition with the 'any' behavior.""" - await async_setup_component(hass, "light", {}) - other_entity_ids = set(target_lights) - {entity_id} # Set all lights, including the tested light, to the initial state @@ -235,8 +233,6 @@ async def test_light_state_condition_behavior_all( other_state: str, ) -> None: """Test the light state condition with the 'all' behavior.""" - await async_setup_component(hass, "light", {}) - # Set state for two switches to ensure that they don't impact the condition hass.states.async_set("switch.label_switch_1", STATE_OFF) hass.states.async_set("switch.label_switch_2", STATE_ON) diff --git a/tests/components/light/test_trigger.py b/tests/components/light/test_trigger.py index da9ef877710..2be6b4bfac1 100644 --- a/tests/components/light/test_trigger.py +++ b/tests/components/light/test_trigger.py @@ -7,7 +7,6 @@ import pytest from homeassistant.const import ATTR_LABEL_ID, CONF_ENTITY_ID, STATE_OFF, STATE_ON from homeassistant.core import HomeAssistant, ServiceCall -from homeassistant.setup import async_setup_component from tests.components import ( StateDescription, @@ -91,8 +90,6 @@ async def test_light_state_trigger_behavior_any( states: list[StateDescription], ) -> None: """Test that the light state trigger fires when any light state changes to a specific state.""" - await async_setup_component(hass, "light", {}) - other_entity_ids = set(target_lights) - {entity_id} # Set all lights, including the tested light, to the initial state @@ -150,8 +147,6 @@ async def test_light_state_trigger_behavior_first( states: list[StateDescription], ) -> None: """Test that the light state trigger fires when the first light changes to a specific state.""" - await async_setup_component(hass, "light", {}) - other_entity_ids = set(target_lights) - {entity_id} # Set all lights, including the tested light, to the initial state @@ -208,8 +203,6 @@ async def test_light_state_trigger_behavior_last( states: list[StateDescription], ) -> None: """Test that the light state trigger fires when the last light changes to a specific state.""" - await async_setup_component(hass, "light", {}) - other_entity_ids = set(target_lights) - {entity_id} # Set all lights, including the tested light, to the initial state diff --git a/tests/components/media_player/test_trigger.py b/tests/components/media_player/test_trigger.py index 89daa72a03a..3338474fdd2 100644 --- a/tests/components/media_player/test_trigger.py +++ b/tests/components/media_player/test_trigger.py @@ -8,7 +8,6 @@ import pytest from homeassistant.components.media_player import MediaPlayerState from homeassistant.const import ATTR_LABEL_ID, CONF_ENTITY_ID from homeassistant.core import HomeAssistant, ServiceCall -from homeassistant.setup import async_setup_component from tests.components import ( StateDescription, @@ -94,8 +93,6 @@ async def test_media_player_state_trigger_behavior_any( states: list[StateDescription], ) -> None: """Test that the media player state trigger fires when any media player state changes to a specific state.""" - await async_setup_component(hass, "media_player", {}) - other_entity_ids = set(target_media_players) - {entity_id} # Set all media players, including the tested media player, to the initial state @@ -156,8 +153,6 @@ async def test_media_player_state_trigger_behavior_first( states: list[StateDescription], ) -> None: """Test that the media player state trigger fires when the first media player changes to a specific state.""" - await async_setup_component(hass, "media_player", {}) - other_entity_ids = set(target_media_players) - {entity_id} # Set all media players, including the tested media player, to the initial state @@ -217,8 +212,6 @@ async def test_media_player_state_trigger_behavior_last( states: list[StateDescription], ) -> None: """Test that the media player state trigger fires when the last media player changes to a specific state.""" - await async_setup_component(hass, "media_player", {}) - other_entity_ids = set(target_media_players) - {entity_id} # Set all media players, including the tested media player, to the initial state diff --git a/tests/components/text/test_trigger.py b/tests/components/text/test_trigger.py index 34d76088ffc..aa8b66ec2df 100644 --- a/tests/components/text/test_trigger.py +++ b/tests/components/text/test_trigger.py @@ -12,7 +12,6 @@ from homeassistant.const import ( STATE_UNKNOWN, ) from homeassistant.core import HomeAssistant, ServiceCall -from homeassistant.setup import async_setup_component from tests.components import ( StateDescription, @@ -153,8 +152,6 @@ async def test_text_state_trigger_behavior_any( states: list[StateDescription], ) -> None: """Test that the text state trigger fires when any text state changes to a specific state.""" - await async_setup_component(hass, "text", {}) - other_entity_ids = set(target_texts) - {entity_id} # Set all texts, including the tested text, to the initial state diff --git a/tests/components/vacuum/test_trigger.py b/tests/components/vacuum/test_trigger.py index a17a505590f..6733e8fddc9 100644 --- a/tests/components/vacuum/test_trigger.py +++ b/tests/components/vacuum/test_trigger.py @@ -8,7 +8,6 @@ import pytest from homeassistant.components.vacuum import VacuumActivity from homeassistant.const import ATTR_LABEL_ID, CONF_ENTITY_ID from homeassistant.core import HomeAssistant, ServiceCall -from homeassistant.setup import async_setup_component from tests.components import ( StateDescription, @@ -105,8 +104,6 @@ async def test_vacuum_state_trigger_behavior_any( states: list[StateDescription], ) -> None: """Test that the vacuum state trigger fires when any vacuum state changes to a specific state.""" - await async_setup_component(hass, "vacuum", {}) - other_entity_ids = set(target_vacuums) - {entity_id} # Set all vacuums, including the tested one, to the initial state @@ -174,8 +171,6 @@ async def test_vacuum_state_trigger_behavior_first( states: list[StateDescription], ) -> None: """Test that the vacuum state trigger fires when the first vacuum changes to a specific state.""" - await async_setup_component(hass, "vacuum", {}) - other_entity_ids = set(target_vacuums) - {entity_id} # Set all vacuums, including the tested one, to the initial state @@ -242,8 +237,6 @@ async def test_vacuum_state_trigger_behavior_last( states: list[StateDescription], ) -> None: """Test that the vacuum state trigger fires when the last vacuum changes to a specific state.""" - await async_setup_component(hass, "vacuum", {}) - other_entity_ids = set(target_vacuums) - {entity_id} # Set all vacuums, including the tested one, to the initial state