diff --git a/tests/components/zha/test_repairs.py b/tests/components/zha/test_repairs.py index c254a9c15fe..5e128cc464a 100644 --- a/tests/components/zha/test_repairs.py +++ b/tests/components/zha/test_repairs.py @@ -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