Reset logging level in esphome test (#143291)

This commit is contained in:
Marc Mueller 2025-04-19 23:59:45 +02:00 committed by GitHub
parent ec55f716e1
commit 8f4435019b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -958,33 +958,35 @@ async def test_debug_logging(
[APIClient, list[EntityInfo], list[UserService], list[EntityState]], [APIClient, list[EntityInfo], list[UserService], list[EntityState]],
Awaitable[MockConfigEntry], Awaitable[MockConfigEntry],
], ],
caplog: pytest.LogCaptureFixture,
) -> None: ) -> None:
"""Test enabling and disabling debug logging.""" """Test enabling and disabling debug logging."""
assert await async_setup_component(hass, "logger", {"logger": {}}) with caplog.at_level(logging.NOTSET, "homeassistant.components.esphome"):
await mock_generic_device_entry( assert await async_setup_component(hass, "logger", {"logger": {}})
mock_client=mock_client, await mock_generic_device_entry(
entity_info=[], mock_client=mock_client,
user_service=[], entity_info=[],
states=[], user_service=[],
) states=[],
await hass.services.async_call( )
"logger", await hass.services.async_call(
"set_level", "logger",
{"homeassistant.components.esphome": "DEBUG"}, "set_level",
blocking=True, {"homeassistant.components.esphome": "DEBUG"},
) blocking=True,
await hass.async_block_till_done() )
mock_client.set_debug.assert_has_calls([call(True)]) await hass.async_block_till_done()
mock_client.set_debug.assert_has_calls([call(True)])
mock_client.reset_mock() mock_client.reset_mock()
await hass.services.async_call( await hass.services.async_call(
"logger", "logger",
"set_level", "set_level",
{"homeassistant.components.esphome": "WARNING"}, {"homeassistant.components.esphome": "WARNING"},
blocking=True, blocking=True,
) )
await hass.async_block_till_done() await hass.async_block_till_done()
mock_client.set_debug.assert_has_calls([call(False)]) mock_client.set_debug.assert_has_calls([call(False)])
async def test_esphome_device_with_dash_in_name_user_services( async def test_esphome_device_with_dash_in_name_user_services(