diff --git a/tests/components/mqtt/test_fan.py b/tests/components/mqtt/test_fan.py index 80e45c87789..2d1d717c58f 100644 --- a/tests/components/mqtt/test_fan.py +++ b/tests/components/mqtt/test_fan.py @@ -83,10 +83,9 @@ DEFAULT_CONFIG = { @pytest.mark.parametrize("hass_config", [{mqtt.DOMAIN: {fan.DOMAIN: {"name": "test"}}}]) +@pytest.mark.usefixtures("hass") async def test_fail_setup_if_no_command_topic( - hass: HomeAssistant, - caplog: pytest.LogCaptureFixture, - mqtt_mock_entry: MqttMockHAClientGenerator, + caplog: pytest.LogCaptureFixture, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: """Test if command fails with command topic.""" assert await mqtt_mock_entry() @@ -611,8 +610,7 @@ async def test_controlling_state_via_topic_and_json_message_shared_topic( ], ) async def test_sending_mqtt_commands_and_optimistic( - hass: HomeAssistant, - mqtt_mock_entry: MqttMockHAClientGenerator, + hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: """Test optimistic mode without state topic.""" mqtt_mock = await mqtt_mock_entry() @@ -861,9 +859,7 @@ async def test_sending_mqtt_commands_with_alternate_speed_range( ], ) async def test_sending_mqtt_commands_and_optimistic_no_legacy( - hass: HomeAssistant, - mqtt_mock_entry: MqttMockHAClientGenerator, - caplog: pytest.LogCaptureFixture, + hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: """Test optimistic mode without state topic without legacy speed command topic.""" mqtt_mock = await mqtt_mock_entry() @@ -1005,8 +1001,7 @@ async def test_sending_mqtt_commands_and_optimistic_no_legacy( ], ) async def test_sending_mqtt_command_templates_( - hass: HomeAssistant, - mqtt_mock_entry: MqttMockHAClientGenerator, + hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: """Test optimistic mode without state topic without legacy speed command topic.""" mqtt_mock = await mqtt_mock_entry() @@ -1166,8 +1161,7 @@ async def test_sending_mqtt_command_templates_( ], ) async def test_sending_mqtt_commands_and_optimistic_no_percentage_topic( - hass: HomeAssistant, - mqtt_mock_entry: MqttMockHAClientGenerator, + hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: """Test optimistic mode without state topic without percentage command topic.""" mqtt_mock = await mqtt_mock_entry() @@ -1237,8 +1231,7 @@ async def test_sending_mqtt_commands_and_optimistic_no_percentage_topic( ], ) async def test_sending_mqtt_commands_and_explicit_optimistic( - hass: HomeAssistant, - mqtt_mock_entry: MqttMockHAClientGenerator, + hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: """Test optimistic mode with state topic and turn on attributes.""" mqtt_mock = await mqtt_mock_entry() @@ -1533,9 +1526,7 @@ async def test_encoding_subscribable_topics( ], ) async def test_attributes( - hass: HomeAssistant, - mqtt_mock_entry: MqttMockHAClientGenerator, - caplog: pytest.LogCaptureFixture, + hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: """Test attributes.""" await mqtt_mock_entry() @@ -2215,8 +2206,7 @@ async def test_publishing_with_custom_encoding( async def test_reloadable( - hass: HomeAssistant, - mqtt_client_mock: MqttMockPahoClient, + hass: HomeAssistant, mqtt_client_mock: MqttMockPahoClient ) -> None: """Test reloading the MQTT platform.""" domain = fan.DOMAIN @@ -2239,8 +2229,7 @@ async def test_setup_manual_entity_from_yaml( async def test_unload_entry( - hass: HomeAssistant, - mqtt_mock_entry: MqttMockHAClientGenerator, + hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: """Test unloading the config entry.""" domain = fan.DOMAIN diff --git a/tests/components/mqtt/test_humidifier.py b/tests/components/mqtt/test_humidifier.py index b583412b4ff..05180c17b2f 100644 --- a/tests/components/mqtt/test_humidifier.py +++ b/tests/components/mqtt/test_humidifier.py @@ -83,17 +83,16 @@ DEFAULT_CONFIG = { } -async def async_turn_on( - hass: HomeAssistant, - entity_id=ENTITY_MATCH_ALL, -) -> None: +async def async_turn_on(hass: HomeAssistant, entity_id: str = ENTITY_MATCH_ALL) -> None: """Turn all or specified humidifier on.""" data = {ATTR_ENTITY_ID: entity_id} if entity_id else {} await hass.services.async_call(DOMAIN, SERVICE_TURN_ON, data, blocking=True) -async def async_turn_off(hass: HomeAssistant, entity_id=ENTITY_MATCH_ALL) -> None: +async def async_turn_off( + hass: HomeAssistant, entity_id: str = ENTITY_MATCH_ALL +) -> None: """Turn all or specified humidier off.""" data = {ATTR_ENTITY_ID: entity_id} if entity_id else {} @@ -101,7 +100,7 @@ async def async_turn_off(hass: HomeAssistant, entity_id=ENTITY_MATCH_ALL) -> Non async def async_set_mode( - hass: HomeAssistant, entity_id=ENTITY_MATCH_ALL, mode: str | None = None + hass: HomeAssistant, entity_id: str = ENTITY_MATCH_ALL, mode: str | None = None ) -> None: """Set mode for all or specified humidifier.""" data = { @@ -114,7 +113,7 @@ async def async_set_mode( async def async_set_humidity( - hass: HomeAssistant, entity_id=ENTITY_MATCH_ALL, humidity: int | None = None + hass: HomeAssistant, entity_id: str = ENTITY_MATCH_ALL, humidity: int | None = None ) -> None: """Set target humidity for all or specified humidifier.""" data = { @@ -129,10 +128,9 @@ async def async_set_humidity( @pytest.mark.parametrize( "hass_config", [{mqtt.DOMAIN: {humidifier.DOMAIN: {"name": "test"}}}] ) +@pytest.mark.usefixtures("hass") async def test_fail_setup_if_no_command_topic( - hass: HomeAssistant, - mqtt_mock_entry: MqttMockHAClientGenerator, - caplog: pytest.LogCaptureFixture, + mqtt_mock_entry: MqttMockHAClientGenerator, caplog: pytest.LogCaptureFixture ) -> None: """Test if command fails with command topic.""" assert await mqtt_mock_entry() @@ -892,9 +890,7 @@ async def test_encoding_subscribable_topics( ], ) async def test_attributes( - hass: HomeAssistant, - mqtt_mock_entry: MqttMockHAClientGenerator, - caplog: pytest.LogCaptureFixture, + hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: """Test attributes.""" await mqtt_mock_entry() @@ -1048,9 +1044,7 @@ async def test_attributes( ], ) async def test_validity_configurations( - hass: HomeAssistant, - mqtt_mock_entry: MqttMockHAClientGenerator, - valid: bool, + hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, valid: bool ) -> None: """Test validity of configurations.""" await mqtt_mock_entry() @@ -1499,8 +1493,7 @@ async def test_publishing_with_custom_encoding( async def test_reloadable( - hass: HomeAssistant, - mqtt_client_mock: MqttMockPahoClient, + hass: HomeAssistant, mqtt_client_mock: MqttMockPahoClient ) -> None: """Test reloading the MQTT platform.""" domain = humidifier.DOMAIN @@ -1523,8 +1516,7 @@ async def test_setup_manual_entity_from_yaml( async def test_unload_config_entry( - hass: HomeAssistant, - mqtt_mock_entry: MqttMockHAClientGenerator, + hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: """Test unloading the config entry.""" domain = humidifier.DOMAIN diff --git a/tests/components/mqtt/test_image.py b/tests/components/mqtt/test_image.py index a299474c0ac..29109ee12f4 100644 --- a/tests/components/mqtt/test_image.py +++ b/tests/components/mqtt/test_image.py @@ -356,7 +356,6 @@ async def test_image_from_url_content_type( hass: HomeAssistant, hass_client_no_auth: ClientSessionGenerator, mqtt_mock_entry: MqttMockHAClientGenerator, - caplog: pytest.LogCaptureFixture, content_type: str, setup_ok: bool, ) -> None: @@ -425,7 +424,6 @@ async def test_image_from_url_fails( hass: HomeAssistant, hass_client_no_auth: ClientSessionGenerator, mqtt_mock_entry: MqttMockHAClientGenerator, - caplog: pytest.LogCaptureFixture, side_effect: Exception, ) -> None: """Test setup with minimum configuration.""" @@ -501,9 +499,8 @@ async def test_image_from_url_fails( ), ], ) +@pytest.mark.usesfixtures("hass", "hass_client_no_auth") async def test_image_config_fails( - hass: HomeAssistant, - hass_client_no_auth: ClientSessionGenerator, mqtt_mock_entry: MqttMockHAClientGenerator, caplog: pytest.LogCaptureFixture, error_msg: str, @@ -721,11 +718,7 @@ async def test_entity_id_update_subscriptions( ) -> None: """Test MQTT subscriptions are managed when entity_id is updated.""" await help_test_entity_id_update_subscriptions( - hass, - mqtt_mock_entry, - image.DOMAIN, - DEFAULT_CONFIG, - ["test_topic"], + hass, mqtt_mock_entry, image.DOMAIN, DEFAULT_CONFIG, ["test_topic"] ) @@ -754,8 +747,7 @@ async def test_entity_debug_info_message( async def test_reloadable( - hass: HomeAssistant, - mqtt_client_mock: MqttMockPahoClient, + hass: HomeAssistant, mqtt_client_mock: MqttMockPahoClient ) -> None: """Test reloading the MQTT platform.""" domain = image.DOMAIN @@ -774,8 +766,7 @@ async def test_setup_manual_entity_from_yaml( async def test_unload_entry( - hass: HomeAssistant, - mqtt_mock_entry: MqttMockHAClientGenerator, + hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: """Test unloading the config entry.""" domain = image.DOMAIN