Fix zha test by tweaking the log level (#115368)

This commit is contained in:
Jan Bouwhuis 2024-04-11 01:10:46 +02:00 committed by GitHub
parent bbecb98927
commit be8adf9d29
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -265,17 +265,27 @@ async def test_no_warn_on_socket(hass: HomeAssistant) -> None:
mock_probe.assert_not_called()
async def test_probe_failure_exception_handling(caplog) -> None:
async def test_probe_failure_exception_handling(
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test that probe failures are handled gracefully."""
logger = logging.getLogger(
"homeassistant.components.zha.repairs.wrong_silabs_firmware"
)
orig_level = logger.level
with (
caplog.at_level(logging.DEBUG),
patch(
"homeassistant.components.zha.repairs.wrong_silabs_firmware.Flasher.probe_app_type",
side_effect=RuntimeError(),
),
caplog.at_level(logging.DEBUG),
) as mock_probe_app_type,
):
logger.setLevel(logging.DEBUG)
await probe_silabs_firmware_type("/dev/ttyZigbee")
logger.setLevel(orig_level)
mock_probe_app_type.assert_awaited()
assert "Failed to probe application type" in caplog.text