From c7e065c413bc5f78284ed0eede7d4db3ad92522e Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 5 Jun 2024 09:20:08 +0200 Subject: [PATCH] Move enable_custom_integrations fixture to decorator (#118844) --- tests/components/analytics/test_analytics.py | 2 +- tests/components/button/test_init.py | 13 +++++------- .../components/config/test_config_entries.py | 18 +++++++--------- .../device_sun_light_trigger/test_init.py | 5 ++--- tests/components/diagnostics/test_init.py | 5 ++--- tests/components/group/test_switch.py | 7 ++++--- .../components/image_processing/test_init.py | 6 +++--- .../components/input_boolean/test_recorder.py | 8 +++---- .../components/input_button/test_recorder.py | 8 +++---- .../input_datetime/test_recorder.py | 8 +++---- .../components/input_number/test_recorder.py | 8 +++---- .../components/input_select/test_recorder.py | 8 +++---- tests/components/input_text/test_recorder.py | 8 +++---- tests/components/light/test_device_action.py | 4 ++-- .../components/light/test_device_condition.py | 4 ++-- tests/components/light/test_device_trigger.py | 6 +++--- tests/components/light/test_init.py | 2 +- tests/components/person/test_recorder.py | 6 +++--- tests/components/remote/test_device_action.py | 4 ++-- .../remote/test_device_condition.py | 6 +++--- .../components/remote/test_device_trigger.py | 6 +++--- tests/components/scene/test_init.py | 21 +++++++++---------- tests/components/schedule/test_recorder.py | 10 ++++----- .../sensor/test_device_condition.py | 10 ++++----- .../components/sensor/test_device_trigger.py | 12 +++++------ tests/components/sensor/test_recorder.py | 5 ++--- tests/components/switch/test_device_action.py | 4 ++-- .../switch/test_device_condition.py | 6 +++--- .../components/switch/test_device_trigger.py | 6 +++--- tests/components/switch/test_init.py | 11 +++++----- tests/components/trace/test_websocket_api.py | 4 ++-- tests/components/webhook/test_init.py | 2 +- 32 files changed, 112 insertions(+), 121 deletions(-) diff --git a/tests/components/analytics/test_analytics.py b/tests/components/analytics/test_analytics.py index 8b86c505517..60882cda874 100644 --- a/tests/components/analytics/test_analytics.py +++ b/tests/components/analytics/test_analytics.py @@ -566,10 +566,10 @@ async def test_reusing_uuid( assert analytics.uuid == "NOT_MOCK_UUID" +@pytest.mark.usefixtures("enable_custom_integrations") async def test_custom_integrations( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, - enable_custom_integrations: None, caplog: pytest.LogCaptureFixture, installation_type_mock: Generator[Any, Any, None], snapshot: SnapshotAssertion, diff --git a/tests/components/button/test_init.py b/tests/components/button/test_init.py index 6cb2f1a5700..02a320ea3fd 100644 --- a/tests/components/button/test_init.py +++ b/tests/components/button/test_init.py @@ -55,12 +55,11 @@ async def test_button(hass: HomeAssistant) -> None: assert button.press.called +@pytest.mark.usefixtures("enable_custom_integrations", "setup_platform") async def test_custom_integration( hass: HomeAssistant, caplog: pytest.LogCaptureFixture, - enable_custom_integrations: None, freezer: FrozenDateTimeFactory, - setup_platform: None, ) -> None: """Test we integration.""" assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}}) @@ -95,9 +94,8 @@ async def test_custom_integration( assert hass.states.get("button.button_1").state == new_time_isoformat -async def test_restore_state( - hass: HomeAssistant, enable_custom_integrations: None, setup_platform: None -) -> None: +@pytest.mark.usefixtures("enable_custom_integrations", "setup_platform") +async def test_restore_state(hass: HomeAssistant) -> None: """Test we restore state integration.""" mock_restore_cache(hass, (State("button.button_1", "2021-01-01T23:59:59+00:00"),)) @@ -107,9 +105,8 @@ async def test_restore_state( assert hass.states.get("button.button_1").state == "2021-01-01T23:59:59+00:00" -async def test_restore_state_does_not_restore_unavailable( - hass: HomeAssistant, enable_custom_integrations: None, setup_platform: None -) -> None: +@pytest.mark.usefixtures("enable_custom_integrations", "setup_platform") +async def test_restore_state_does_not_restore_unavailable(hass: HomeAssistant) -> None: """Test we restore state integration except for unavailable.""" mock_restore_cache(hass, (State("button.button_1", STATE_UNAVAILABLE),)) diff --git a/tests/components/config/test_config_entries.py b/tests/components/config/test_config_entries.py index 320bc91fae4..17cc7d8c6de 100644 --- a/tests/components/config/test_config_entries.py +++ b/tests/components/config/test_config_entries.py @@ -507,9 +507,8 @@ async def test_abort(hass: HomeAssistant, client) -> None: } -async def test_create_account( - hass: HomeAssistant, client, enable_custom_integrations: None -) -> None: +@pytest.mark.usefixtures("enable_custom_integrations") +async def test_create_account(hass: HomeAssistant, client) -> None: """Test a flow that creates an account.""" mock_platform(hass, "test.config_flow", None) @@ -566,9 +565,8 @@ async def test_create_account( } -async def test_two_step_flow( - hass: HomeAssistant, client, enable_custom_integrations: None -) -> None: +@pytest.mark.usefixtures("enable_custom_integrations") +async def test_two_step_flow(hass: HomeAssistant, client) -> None: """Test we can finish a two step flow.""" mock_integration( hass, MockModule("test", async_setup_entry=AsyncMock(return_value=True)) @@ -2227,9 +2225,8 @@ async def test_flow_with_multiple_schema_errors_base( } -async def test_supports_reconfigure( - hass: HomeAssistant, client, enable_custom_integrations: None -) -> None: +@pytest.mark.usefixtures("enable_custom_integrations") +async def test_supports_reconfigure(hass: HomeAssistant, client) -> None: """Test a flow that support reconfigure step.""" mock_platform(hass, "test.config_flow", None) @@ -2317,8 +2314,9 @@ async def test_supports_reconfigure( } +@pytest.mark.usefixtures("enable_custom_integrations") async def test_does_not_support_reconfigure( - hass: HomeAssistant, client: TestClient, enable_custom_integrations: None + hass: HomeAssistant, client: TestClient ) -> None: """Test a flow that does not support reconfigure step.""" mock_platform(hass, "test.config_flow", None) diff --git a/tests/components/device_sun_light_trigger/test_init.py b/tests/components/device_sun_light_trigger/test_init.py index 5f44593aabe..65afd5743f5 100644 --- a/tests/components/device_sun_light_trigger/test_init.py +++ b/tests/components/device_sun_light_trigger/test_init.py @@ -108,9 +108,8 @@ async def test_lights_on_when_sun_sets( ) -async def test_lights_turn_off_when_everyone_leaves( - hass: HomeAssistant, enable_custom_integrations: None -) -> None: +@pytest.mark.usefixtures("enable_custom_integrations") +async def test_lights_turn_off_when_everyone_leaves(hass: HomeAssistant) -> None: """Test lights turn off when everyone leaves the house.""" assert await async_setup_component( hass, "light", {light.DOMAIN: {CONF_PLATFORM: "test"}} diff --git a/tests/components/diagnostics/test_init.py b/tests/components/diagnostics/test_init.py index 85f0b8fe788..1189cc6a65d 100644 --- a/tests/components/diagnostics/test_init.py +++ b/tests/components/diagnostics/test_init.py @@ -80,10 +80,9 @@ async def test_websocket( } +@pytest.mark.usefixtures("enable_custom_integrations") async def test_download_diagnostics( - hass: HomeAssistant, - hass_client: ClientSessionGenerator, - enable_custom_integrations: None, + hass: HomeAssistant, hass_client: ClientSessionGenerator ) -> None: """Test download diagnostics.""" config_entry = MockConfigEntry(domain="fake_integration") diff --git a/tests/components/group/test_switch.py b/tests/components/group/test_switch.py index 32b21fcb0d7..4230a6ee86f 100644 --- a/tests/components/group/test_switch.py +++ b/tests/components/group/test_switch.py @@ -3,6 +3,8 @@ import asyncio from unittest.mock import patch +import pytest + from homeassistant import config as hass_config from homeassistant.components.group import DOMAIN, SERVICE_RELOAD from homeassistant.components.switch import ( @@ -232,9 +234,8 @@ async def test_state_reporting_all(hass: HomeAssistant) -> None: assert hass.states.get("switch.switch_group").state == STATE_UNAVAILABLE -async def test_service_calls( - hass: HomeAssistant, enable_custom_integrations: None -) -> None: +@pytest.mark.usefixtures("enable_custom_integrations") +async def test_service_calls(hass: HomeAssistant) -> None: """Test service calls.""" await async_setup_component( hass, diff --git a/tests/components/image_processing/test_init.py b/tests/components/image_processing/test_init.py index 2bc093ce9a9..577d3fc47db 100644 --- a/tests/components/image_processing/test_init.py +++ b/tests/components/image_processing/test_init.py @@ -89,11 +89,11 @@ async def test_setup_component_with_service(hass: HomeAssistant) -> None: "homeassistant.components.demo.camera.Path.read_bytes", return_value=b"Test", ) +@pytest.mark.usefixtures("enable_custom_integrations") async def test_get_image_from_camera( mock_camera_read, hass: HomeAssistant, aiohttp_unused_port_factory, - enable_custom_integrations: None, ) -> None: """Grab an image from camera entity.""" await setup_image_processing(hass, aiohttp_unused_port_factory) @@ -112,11 +112,11 @@ async def test_get_image_from_camera( "homeassistant.components.image_processing.async_get_image", side_effect=HomeAssistantError(), ) +@pytest.mark.usefixtures("enable_custom_integrations") async def test_get_image_without_exists_camera( mock_image, hass: HomeAssistant, aiohttp_unused_port_factory, - enable_custom_integrations: None, ) -> None: """Try to get image without exists camera.""" await setup_image_processing(hass, aiohttp_unused_port_factory) @@ -188,10 +188,10 @@ async def test_face_event_call_no_confidence( assert event_data[0]["entity_id"] == "image_processing.demo_face" +@pytest.mark.usefixtures("enable_custom_integrations") async def test_update_missing_camera( hass: HomeAssistant, aiohttp_unused_port_factory, - enable_custom_integrations: None, caplog: pytest.LogCaptureFixture, ) -> None: """Test when entity does not set camera.""" diff --git a/tests/components/input_boolean/test_recorder.py b/tests/components/input_boolean/test_recorder.py index 8f041d6c848..8e2f078a5e4 100644 --- a/tests/components/input_boolean/test_recorder.py +++ b/tests/components/input_boolean/test_recorder.py @@ -4,8 +4,9 @@ from __future__ import annotations from datetime import timedelta +import pytest + from homeassistant.components.input_boolean import DOMAIN -from homeassistant.components.recorder import Recorder from homeassistant.components.recorder.history import get_significant_states from homeassistant.const import ATTR_EDITABLE from homeassistant.core import HomeAssistant @@ -16,9 +17,8 @@ from tests.common import async_fire_time_changed from tests.components.recorder.common import async_wait_recording_done -async def test_exclude_attributes( - recorder_mock: Recorder, hass: HomeAssistant, enable_custom_integrations: None -) -> None: +@pytest.mark.usefixtures("recorder_mock", "enable_custom_integrations") +async def test_exclude_attributes(hass: HomeAssistant) -> None: """Test attributes to be excluded.""" now = dt_util.utcnow() assert await async_setup_component(hass, DOMAIN, {DOMAIN: {"test": {}}}) diff --git a/tests/components/input_button/test_recorder.py b/tests/components/input_button/test_recorder.py index 74023b73342..19ff8427dac 100644 --- a/tests/components/input_button/test_recorder.py +++ b/tests/components/input_button/test_recorder.py @@ -4,8 +4,9 @@ from __future__ import annotations from datetime import timedelta +import pytest + from homeassistant.components.input_button import DOMAIN -from homeassistant.components.recorder import Recorder from homeassistant.components.recorder.history import get_significant_states from homeassistant.const import ATTR_EDITABLE from homeassistant.core import HomeAssistant @@ -16,9 +17,8 @@ from tests.common import async_fire_time_changed from tests.components.recorder.common import async_wait_recording_done -async def test_exclude_attributes( - recorder_mock: Recorder, hass: HomeAssistant, enable_custom_integrations: None -) -> None: +@pytest.mark.usefixtures("recorder_mock", "enable_custom_integrations") +async def test_exclude_attributes(hass: HomeAssistant) -> None: """Test attributes to be excluded.""" now = dt_util.utcnow() assert await async_setup_component(hass, DOMAIN, {DOMAIN: {"test": {}}}) diff --git a/tests/components/input_datetime/test_recorder.py b/tests/components/input_datetime/test_recorder.py index d32e8ec3471..dafe1d5301b 100644 --- a/tests/components/input_datetime/test_recorder.py +++ b/tests/components/input_datetime/test_recorder.py @@ -4,8 +4,9 @@ from __future__ import annotations from datetime import timedelta +import pytest + from homeassistant.components.input_datetime import CONF_HAS_DATE, CONF_HAS_TIME, DOMAIN -from homeassistant.components.recorder import Recorder from homeassistant.components.recorder.history import get_significant_states from homeassistant.const import ATTR_EDITABLE from homeassistant.core import HomeAssistant @@ -16,9 +17,8 @@ from tests.common import async_fire_time_changed from tests.components.recorder.common import async_wait_recording_done -async def test_exclude_attributes( - recorder_mock: Recorder, hass: HomeAssistant, enable_custom_integrations: None -) -> None: +@pytest.mark.usefixtures("recorder_mock", "enable_custom_integrations") +async def test_exclude_attributes(hass: HomeAssistant) -> None: """Test attributes to be excluded.""" now = dt_util.utcnow() assert await async_setup_component( diff --git a/tests/components/input_number/test_recorder.py b/tests/components/input_number/test_recorder.py index 78f709511de..986f53e9311 100644 --- a/tests/components/input_number/test_recorder.py +++ b/tests/components/input_number/test_recorder.py @@ -4,6 +4,8 @@ from __future__ import annotations from datetime import timedelta +import pytest + from homeassistant.components.input_number import ( ATTR_MAX, ATTR_MIN, @@ -11,7 +13,6 @@ from homeassistant.components.input_number import ( ATTR_STEP, DOMAIN, ) -from homeassistant.components.recorder import Recorder from homeassistant.components.recorder.history import get_significant_states from homeassistant.const import ATTR_EDITABLE from homeassistant.core import HomeAssistant @@ -22,9 +23,8 @@ from tests.common import async_fire_time_changed from tests.components.recorder.common import async_wait_recording_done -async def test_exclude_attributes( - recorder_mock: Recorder, hass: HomeAssistant, enable_custom_integrations: None -) -> None: +@pytest.mark.usefixtures("recorder_mock", "enable_custom_integrations") +async def test_exclude_attributes(hass: HomeAssistant) -> None: """Test attributes to be excluded.""" now = dt_util.utcnow() assert await async_setup_component( diff --git a/tests/components/input_select/test_recorder.py b/tests/components/input_select/test_recorder.py index b12fe57d431..107608b7774 100644 --- a/tests/components/input_select/test_recorder.py +++ b/tests/components/input_select/test_recorder.py @@ -4,8 +4,9 @@ from __future__ import annotations from datetime import timedelta +import pytest + from homeassistant.components.input_select import ATTR_OPTIONS, DOMAIN -from homeassistant.components.recorder import Recorder from homeassistant.components.recorder.history import get_significant_states from homeassistant.const import ATTR_EDITABLE from homeassistant.core import HomeAssistant @@ -16,9 +17,8 @@ from tests.common import async_fire_time_changed from tests.components.recorder.common import async_wait_recording_done -async def test_exclude_attributes( - recorder_mock: Recorder, hass: HomeAssistant, enable_custom_integrations: None -) -> None: +@pytest.mark.usefixtures("recorder_mock", "enable_custom_integrations") +async def test_exclude_attributes(hass: HomeAssistant) -> None: """Test attributes to be excluded.""" now = dt_util.utcnow() assert await async_setup_component( diff --git a/tests/components/input_text/test_recorder.py b/tests/components/input_text/test_recorder.py index a81160b32c7..21309f0a8ab 100644 --- a/tests/components/input_text/test_recorder.py +++ b/tests/components/input_text/test_recorder.py @@ -4,6 +4,8 @@ from __future__ import annotations from datetime import timedelta +import pytest + from homeassistant.components.input_text import ( ATTR_MAX, ATTR_MIN, @@ -12,7 +14,6 @@ from homeassistant.components.input_text import ( DOMAIN, MODE_TEXT, ) -from homeassistant.components.recorder import Recorder from homeassistant.components.recorder.history import get_significant_states from homeassistant.const import ATTR_EDITABLE from homeassistant.core import HomeAssistant @@ -23,9 +24,8 @@ from tests.common import async_fire_time_changed from tests.components.recorder.common import async_wait_recording_done -async def test_exclude_attributes( - recorder_mock: Recorder, hass: HomeAssistant, enable_custom_integrations: None -) -> None: +@pytest.mark.usefixtures("recorder_mock", "enable_custom_integrations") +async def test_exclude_attributes(hass: HomeAssistant) -> None: """Test attributes to be excluded.""" now = dt_util.utcnow() assert await async_setup_component(hass, DOMAIN, {DOMAIN: {"test": {}}}) diff --git a/tests/components/light/test_device_action.py b/tests/components/light/test_device_action.py index 764321fe346..1013942f96b 100644 --- a/tests/components/light/test_device_action.py +++ b/tests/components/light/test_device_action.py @@ -466,12 +466,12 @@ async def test_get_action_capabilities_features_legacy( assert capabilities == expected +@pytest.mark.usefixtures("enable_custom_integrations") async def test_action( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for turn_on and turn_off actions.""" config_entry = MockConfigEntry(domain="test", data={}) @@ -631,12 +631,12 @@ async def test_action( assert turn_on_calls[-1].data == {"entity_id": entry.entity_id, "flash": FLASH_LONG} +@pytest.mark.usefixtures("enable_custom_integrations") async def test_action_legacy( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for turn_on and turn_off actions.""" config_entry = MockConfigEntry(domain="test", data={}) diff --git a/tests/components/light/test_device_condition.py b/tests/components/light/test_device_condition.py index a5459dd078d..01b735bd5af 100644 --- a/tests/components/light/test_device_condition.py +++ b/tests/components/light/test_device_condition.py @@ -180,12 +180,12 @@ async def test_get_condition_capabilities_legacy( assert capabilities == expected_capabilities +@pytest.mark.usefixtures("enable_custom_integrations") async def test_if_state( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for turn_on and turn_off conditions.""" config_entry = MockConfigEntry(domain="test", data={}) @@ -267,12 +267,12 @@ async def test_if_state( assert calls[1].data["some"] == "is_off event - test_event2" +@pytest.mark.usefixtures("enable_custom_integrations") async def test_if_state_legacy( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for turn_on and turn_off conditions.""" config_entry = MockConfigEntry(domain="test", data={}) diff --git a/tests/components/light/test_device_trigger.py b/tests/components/light/test_device_trigger.py index ca919fc9143..b61b69fef25 100644 --- a/tests/components/light/test_device_trigger.py +++ b/tests/components/light/test_device_trigger.py @@ -184,12 +184,12 @@ async def test_get_trigger_capabilities_legacy( assert capabilities == expected_capabilities +@pytest.mark.usefixtures("enable_custom_integrations") async def test_if_fires_on_state_change( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for turn_on and turn_off triggers firing.""" config_entry = MockConfigEntry(domain="test", data={}) @@ -277,12 +277,12 @@ async def test_if_fires_on_state_change( } +@pytest.mark.usefixtures("enable_custom_integrations") async def test_if_fires_on_state_change_legacy( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for turn_on and turn_off triggers firing.""" config_entry = MockConfigEntry(domain="test", data={}) @@ -331,12 +331,12 @@ async def test_if_fires_on_state_change_legacy( ) +@pytest.mark.usefixtures("enable_custom_integrations") async def test_if_fires_on_state_change_with_for( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for triggers firing with delay.""" config_entry = MockConfigEntry(domain="test", data={}) diff --git a/tests/components/light/test_init.py b/tests/components/light/test_init.py index 6a04d5e33cc..6832b5812e2 100644 --- a/tests/components/light/test_init.py +++ b/tests/components/light/test_init.py @@ -980,9 +980,9 @@ async def test_light_brightness_step(hass: HomeAssistant) -> None: assert entity0.state == "off" # 126 - 126; brightness is 0, light should turn off +@pytest.mark.usefixtures("enable_custom_integrations") async def test_light_brightness_pct_conversion( hass: HomeAssistant, - enable_custom_integrations: None, mock_light_entities: list[MockLight], ) -> None: """Test that light brightness percent conversion.""" diff --git a/tests/components/person/test_recorder.py b/tests/components/person/test_recorder.py index 4d25ce7add4..5551a051df0 100644 --- a/tests/components/person/test_recorder.py +++ b/tests/components/person/test_recorder.py @@ -4,8 +4,9 @@ from __future__ import annotations from datetime import timedelta +import pytest + from homeassistant.components.person import ATTR_DEVICE_TRACKERS, DOMAIN -from homeassistant.components.recorder import Recorder from homeassistant.components.recorder.history import get_significant_states from homeassistant.core import HomeAssistant from homeassistant.setup import async_setup_component @@ -15,10 +16,9 @@ from tests.common import MockUser, async_fire_time_changed from tests.components.recorder.common import async_wait_recording_done +@pytest.mark.usefixtures("recorder_mock", "enable_custom_integrations") async def test_exclude_attributes( - recorder_mock: Recorder, hass: HomeAssistant, - enable_custom_integrations: None, hass_admin_user: MockUser, storage_setup, ) -> None: diff --git a/tests/components/remote/test_device_action.py b/tests/components/remote/test_device_action.py index 9ee48009c11..e228810149c 100644 --- a/tests/components/remote/test_device_action.py +++ b/tests/components/remote/test_device_action.py @@ -109,12 +109,12 @@ async def test_get_actions_hidden_auxiliary( assert actions == unordered(expected_actions) +@pytest.mark.usefixtures("enable_custom_integrations") async def test_action( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for turn_on and turn_off actions.""" config_entry = MockConfigEntry(domain="test", data={}) @@ -184,12 +184,12 @@ async def test_action( assert turn_on_calls[-1].data == {"entity_id": entry.entity_id} +@pytest.mark.usefixtures("enable_custom_integrations") async def test_action_legacy( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for turn_on and turn_off actions.""" config_entry = MockConfigEntry(domain="test", data={}) diff --git a/tests/components/remote/test_device_condition.py b/tests/components/remote/test_device_condition.py index 3e8b331e02b..e0c5f6d862b 100644 --- a/tests/components/remote/test_device_condition.py +++ b/tests/components/remote/test_device_condition.py @@ -178,12 +178,12 @@ async def test_get_condition_capabilities_legacy( assert capabilities == expected_capabilities +@pytest.mark.usefixtures("enable_custom_integrations") async def test_if_state( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for turn_on and turn_off conditions.""" config_entry = MockConfigEntry(domain="test", data={}) @@ -265,12 +265,12 @@ async def test_if_state( assert calls[1].data["some"] == "is_off event - test_event2" +@pytest.mark.usefixtures("enable_custom_integrations") async def test_if_state_legacy( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for turn_on and turn_off conditions.""" config_entry = MockConfigEntry(domain="test", data={}) @@ -324,12 +324,12 @@ async def test_if_state_legacy( assert calls[0].data["some"] == "is_on event - test_event1" +@pytest.mark.usefixtures("enable_custom_integrations") async def test_if_fires_on_for_condition( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for firing if condition is on with delay.""" point1 = dt_util.utcnow() diff --git a/tests/components/remote/test_device_trigger.py b/tests/components/remote/test_device_trigger.py index 8c0d6d01051..7e8f91a91dc 100644 --- a/tests/components/remote/test_device_trigger.py +++ b/tests/components/remote/test_device_trigger.py @@ -176,12 +176,12 @@ async def test_get_trigger_capabilities_legacy( assert capabilities == expected_capabilities +@pytest.mark.usefixtures("enable_custom_integrations") async def test_if_fires_on_state_change( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for turn_on and turn_off triggers firing.""" config_entry = MockConfigEntry(domain="test", data={}) @@ -286,12 +286,12 @@ async def test_if_fires_on_state_change( } +@pytest.mark.usefixtures("enable_custom_integrations") async def test_if_fires_on_state_change_legacy( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for turn_on and turn_off triggers firing.""" config_entry = MockConfigEntry(domain="test", data={}) @@ -346,12 +346,12 @@ async def test_if_fires_on_state_change_legacy( ) +@pytest.mark.usefixtures("enable_custom_integrations") async def test_if_fires_on_state_change_with_for( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for triggers firing with delay.""" config_entry = MockConfigEntry(domain="test", data={}) diff --git a/tests/components/scene/test_init.py b/tests/components/scene/test_init.py index a878b27614e..5afdebda9da 100644 --- a/tests/components/scene/test_init.py +++ b/tests/components/scene/test_init.py @@ -37,8 +37,9 @@ def entities( return entities +@pytest.mark.usefixtures("enable_custom_integrations") async def test_config_yaml_alias_anchor( - hass: HomeAssistant, entities, enable_custom_integrations: None + hass: HomeAssistant, entities: list[MockLight] ) -> None: """Test the usage of YAML aliases and anchors. @@ -84,9 +85,8 @@ async def test_config_yaml_alias_anchor( assert light_2.last_call("turn_on")[1].get("brightness") == 100 -async def test_config_yaml_bool( - hass: HomeAssistant, entities, enable_custom_integrations: None -) -> None: +@pytest.mark.usefixtures("enable_custom_integrations") +async def test_config_yaml_bool(hass: HomeAssistant, entities: list[MockLight]) -> None: """Test parsing of booleans in yaml config.""" light_1, light_2 = await setup_lights(hass, entities) @@ -113,9 +113,8 @@ async def test_config_yaml_bool( assert light_2.last_call("turn_on")[1].get("brightness") == 100 -async def test_activate_scene( - hass: HomeAssistant, entities, enable_custom_integrations: None -) -> None: +@pytest.mark.usefixtures("enable_custom_integrations") +async def test_activate_scene(hass: HomeAssistant, entities: list[MockLight]) -> None: """Test active scene.""" light_1, light_2 = await setup_lights(hass, entities) @@ -167,9 +166,8 @@ async def test_activate_scene( assert calls[0].data.get("transition") == 42 -async def test_restore_state( - hass: HomeAssistant, entities, enable_custom_integrations: None -) -> None: +@pytest.mark.usefixtures("enable_custom_integrations") +async def test_restore_state(hass: HomeAssistant, entities: list[MockLight]) -> None: """Test we restore state integration.""" mock_restore_cache(hass, (State("scene.test", "2021-01-01T23:59:59+00:00"),)) @@ -195,8 +193,9 @@ async def test_restore_state( assert hass.states.get("scene.test").state == "2021-01-01T23:59:59+00:00" +@pytest.mark.usefixtures("enable_custom_integrations") async def test_restore_state_does_not_restore_unavailable( - hass: HomeAssistant, entities, enable_custom_integrations: None + hass: HomeAssistant, entities: list[MockLight] ) -> None: """Test we restore state integration but ignore unavailable.""" mock_restore_cache(hass, (State("scene.test", STATE_UNAVAILABLE),)) diff --git a/tests/components/schedule/test_recorder.py b/tests/components/schedule/test_recorder.py index df28730ee79..a7410472a44 100644 --- a/tests/components/schedule/test_recorder.py +++ b/tests/components/schedule/test_recorder.py @@ -4,7 +4,8 @@ from __future__ import annotations from datetime import timedelta -from homeassistant.components.recorder import Recorder +import pytest + from homeassistant.components.recorder.history import get_significant_states from homeassistant.components.schedule.const import ATTR_NEXT_EVENT, DOMAIN from homeassistant.const import ATTR_EDITABLE, ATTR_FRIENDLY_NAME, ATTR_ICON @@ -16,11 +17,8 @@ from tests.common import async_fire_time_changed from tests.components.recorder.common import async_wait_recording_done -async def test_exclude_attributes( - recorder_mock: Recorder, - hass: HomeAssistant, - enable_custom_integrations: None, -) -> None: +@pytest.mark.usefixtures("recorder_mock", "enable_custom_integrations") +async def test_exclude_attributes(hass: HomeAssistant) -> None: """Test attributes to be excluded.""" now = dt_util.utcnow() assert await async_setup_component( diff --git a/tests/components/sensor/test_device_condition.py b/tests/components/sensor/test_device_condition.py index 4c1f2010c12..02eaa2c9739 100644 --- a/tests/components/sensor/test_device_condition.py +++ b/tests/components/sensor/test_device_condition.py @@ -462,13 +462,13 @@ async def test_get_condition_capabilities_none( assert capabilities == expected_capabilities +@pytest.mark.usefixtures("enable_custom_integrations") async def test_if_state_not_above_below( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], caplog: pytest.LogCaptureFixture, - enable_custom_integrations: None, ) -> None: """Test for bad value conditions.""" config_entry = MockConfigEntry(domain="test", data={}) @@ -505,12 +505,12 @@ async def test_if_state_not_above_below( assert "must contain at least one of below, above" in caplog.text +@pytest.mark.usefixtures("enable_custom_integrations") async def test_if_state_above( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for value conditions.""" config_entry = MockConfigEntry(domain="test", data={}) @@ -574,12 +574,12 @@ async def test_if_state_above( assert calls[0].data["some"] == "event - test_event1" +@pytest.mark.usefixtures("enable_custom_integrations") async def test_if_state_above_legacy( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for value conditions.""" config_entry = MockConfigEntry(domain="test", data={}) @@ -643,12 +643,12 @@ async def test_if_state_above_legacy( assert calls[0].data["some"] == "event - test_event1" +@pytest.mark.usefixtures("enable_custom_integrations") async def test_if_state_below( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for value conditions.""" config_entry = MockConfigEntry(domain="test", data={}) @@ -712,12 +712,12 @@ async def test_if_state_below( assert calls[0].data["some"] == "event - test_event1" +@pytest.mark.usefixtures("enable_custom_integrations") async def test_if_state_between( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for value conditions.""" config_entry = MockConfigEntry(domain="test", data={}) diff --git a/tests/components/sensor/test_device_trigger.py b/tests/components/sensor/test_device_trigger.py index fe188d63078..c98fe1e3a52 100644 --- a/tests/components/sensor/test_device_trigger.py +++ b/tests/components/sensor/test_device_trigger.py @@ -419,13 +419,13 @@ async def test_get_trigger_capabilities_none( assert capabilities == expected_capabilities +@pytest.mark.usefixtures("enable_custom_integrations") async def test_if_fires_not_on_above_below( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], caplog: pytest.LogCaptureFixture, - enable_custom_integrations: None, ) -> None: """Test for value triggers firing.""" config_entry = MockConfigEntry(domain="test", data={}) @@ -459,12 +459,12 @@ async def test_if_fires_not_on_above_below( assert "must contain at least one of below, above" in caplog.text +@pytest.mark.usefixtures("enable_custom_integrations") async def test_if_fires_on_state_above( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for value triggers firing.""" config_entry = MockConfigEntry(domain="test", data={}) @@ -524,12 +524,12 @@ async def test_if_fires_on_state_above( ) +@pytest.mark.usefixtures("enable_custom_integrations") async def test_if_fires_on_state_below( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for value triggers firing.""" config_entry = MockConfigEntry(domain="test", data={}) @@ -589,12 +589,12 @@ async def test_if_fires_on_state_below( ) +@pytest.mark.usefixtures("enable_custom_integrations") async def test_if_fires_on_state_between( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for value triggers firing.""" config_entry = MockConfigEntry(domain="test", data={}) @@ -666,12 +666,12 @@ async def test_if_fires_on_state_between( ) +@pytest.mark.usefixtures("enable_custom_integrations") async def test_if_fires_on_state_legacy( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for value triggers firing.""" config_entry = MockConfigEntry(domain="test", data={}) @@ -731,12 +731,12 @@ async def test_if_fires_on_state_legacy( ) +@pytest.mark.usefixtures("enable_custom_integrations") async def test_if_fires_on_state_change_with_for( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for triggers firing with delay.""" config_entry = MockConfigEntry(domain="test", data={}) diff --git a/tests/components/sensor/test_recorder.py b/tests/components/sensor/test_recorder.py index ec43d81fc4a..ea02674a8d1 100644 --- a/tests/components/sensor/test_recorder.py +++ b/tests/components/sensor/test_recorder.py @@ -5234,9 +5234,8 @@ async def async_record_states_partially_unavailable(hass, zero, entity_id, attri return four, states -async def test_exclude_attributes( - hass: HomeAssistant, enable_custom_integrations: None -) -> None: +@pytest.mark.usefixtures("enable_custom_integrations") +async def test_exclude_attributes(hass: HomeAssistant) -> None: """Test sensor attributes to be excluded.""" entity0 = MockSensor( has_entity_name=True, diff --git a/tests/components/switch/test_device_action.py b/tests/components/switch/test_device_action.py index 2a49dd99c90..ed3ff6f55ac 100644 --- a/tests/components/switch/test_device_action.py +++ b/tests/components/switch/test_device_action.py @@ -110,12 +110,12 @@ async def test_get_actions_hidden_auxiliary( assert actions == unordered(expected_actions) +@pytest.mark.usefixtures("enable_custom_integrations") async def test_action( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for turn_on and turn_off actions.""" config_entry = MockConfigEntry(domain="test", data={}) @@ -185,12 +185,12 @@ async def test_action( assert turn_on_calls[-1].data == {"entity_id": entry.entity_id} +@pytest.mark.usefixtures("enable_custom_integrations") async def test_action_legacy( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for turn_on and turn_off actions.""" config_entry = MockConfigEntry(domain="test", data={}) diff --git a/tests/components/switch/test_device_condition.py b/tests/components/switch/test_device_condition.py index df7f39b82fb..43a91b8628a 100644 --- a/tests/components/switch/test_device_condition.py +++ b/tests/components/switch/test_device_condition.py @@ -178,12 +178,12 @@ async def test_get_condition_capabilities_legacy( assert capabilities == expected_capabilities +@pytest.mark.usefixtures("enable_custom_integrations") async def test_if_state( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for turn_on and turn_off conditions.""" config_entry = MockConfigEntry(domain="test", data={}) @@ -265,12 +265,12 @@ async def test_if_state( assert calls[1].data["some"] == "is_off event - test_event2" +@pytest.mark.usefixtures("enable_custom_integrations") async def test_if_state_legacy( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for turn_on and turn_off conditions.""" config_entry = MockConfigEntry(domain="test", data={}) @@ -323,12 +323,12 @@ async def test_if_state_legacy( assert calls[0].data["some"] == "is_on event - test_event1" +@pytest.mark.usefixtures("enable_custom_integrations") async def test_if_fires_on_for_condition( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for firing if condition is on with delay.""" point1 = dt_util.utcnow() diff --git a/tests/components/switch/test_device_trigger.py b/tests/components/switch/test_device_trigger.py index 5b210e9ae3f..96479ba1900 100644 --- a/tests/components/switch/test_device_trigger.py +++ b/tests/components/switch/test_device_trigger.py @@ -176,12 +176,12 @@ async def test_get_trigger_capabilities_legacy( assert capabilities == expected_capabilities +@pytest.mark.usefixtures("enable_custom_integrations") async def test_if_fires_on_state_change( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for turn_on and turn_off triggers firing.""" config_entry = MockConfigEntry(domain="test", data={}) @@ -287,12 +287,12 @@ async def test_if_fires_on_state_change( } +@pytest.mark.usefixtures("enable_custom_integrations") async def test_if_fires_on_state_change_legacy( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for turn_on and turn_off triggers firing.""" config_entry = MockConfigEntry(domain="test", data={}) @@ -348,12 +348,12 @@ async def test_if_fires_on_state_change_legacy( ) +@pytest.mark.usefixtures("enable_custom_integrations") async def test_if_fires_on_state_change_with_for( hass: HomeAssistant, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, calls: list[ServiceCall], - enable_custom_integrations: None, ) -> None: """Test for triggers firing with delay.""" config_entry = MockConfigEntry(domain="test", data={}) diff --git a/tests/components/switch/test_init.py b/tests/components/switch/test_init.py index aa3e4ccce58..989b10c11d6 100644 --- a/tests/components/switch/test_init.py +++ b/tests/components/switch/test_init.py @@ -20,15 +20,16 @@ from tests.common import ( @pytest.fixture(autouse=True) -def entities(hass: HomeAssistant, mock_switch_entities: list[MockSwitch]): +def entities( + hass: HomeAssistant, mock_switch_entities: list[MockSwitch] +) -> list[MockSwitch]: """Initialize the test switch.""" setup_test_component_platform(hass, switch.DOMAIN, mock_switch_entities) return mock_switch_entities -async def test_methods( - hass: HomeAssistant, entities, enable_custom_integrations: None -) -> None: +@pytest.mark.usefixtures("enable_custom_integrations") +async def test_methods(hass: HomeAssistant, entities: list[MockSwitch]) -> None: """Test is_on, turn_on, turn_off methods.""" switch_1, switch_2, switch_3 = entities assert await async_setup_component( @@ -60,11 +61,11 @@ async def test_methods( assert switch.is_on(hass, switch_3.entity_id) +@pytest.mark.usefixtures("enable_custom_integrations") async def test_switch_context( hass: HomeAssistant, entities, hass_admin_user: MockUser, - enable_custom_integrations: None, ) -> None: """Test that switch context works.""" assert await async_setup_component(hass, "switch", {"switch": {"platform": "test"}}) diff --git a/tests/components/trace/test_websocket_api.py b/tests/components/trace/test_websocket_api.py index 91e651ba6e3..92ba2c67020 100644 --- a/tests/components/trace/test_websocket_api.py +++ b/tests/components/trace/test_websocket_api.py @@ -119,6 +119,7 @@ async def _assert_contexts(client, next_id, contexts, domain=None, item_id=None) ("script", "sequence", [set(), set()], [UNDEFINED, UNDEFINED], "id", []), ], ) +@pytest.mark.usefixtures("enable_custom_integrations") async def test_get_trace( hass: HomeAssistant, hass_storage: dict[str, Any], @@ -129,7 +130,6 @@ async def test_get_trace( trigger, context_key, condition_results, - enable_custom_integrations: None, ) -> None: """Test tracing a script or automation.""" await async_setup_component(hass, "homeassistant", {}) @@ -1573,10 +1573,10 @@ async def test_script_mode_2( assert trace["script_execution"] == "finished" +@pytest.mark.usefixtures("enable_custom_integrations") async def test_trace_blueprint_automation( hass: HomeAssistant, hass_ws_client: WebSocketGenerator, - enable_custom_integrations: None, ) -> None: """Test trace of blueprint automation.""" await async_setup_component(hass, "homeassistant", {}) diff --git a/tests/components/webhook/test_init.py b/tests/components/webhook/test_init.py index 826c65cf6bc..b3d309f1f24 100644 --- a/tests/components/webhook/test_init.py +++ b/tests/components/webhook/test_init.py @@ -249,11 +249,11 @@ async def test_webhook_local_only(hass: HomeAssistant, mock_client) -> None: assert len(hooks) == 1 +@pytest.mark.usefixtures("enable_custom_integrations") async def test_listing_webhook( hass: HomeAssistant, hass_ws_client: WebSocketGenerator, hass_access_token: str, - enable_custom_integrations: None, ) -> None: """Test unregistering a webhook.""" assert await async_setup_component(hass, "webhook", {})