diff --git a/tests/components/modbus/test_init.py b/tests/components/modbus/test_init.py index 3b704eff161..2a212535916 100644 --- a/tests/components/modbus/test_init.py +++ b/tests/components/modbus/test_init.py @@ -862,3 +862,20 @@ async def test_integration_reload( async_fire_time_changed(hass) await hass.async_block_till_done() assert "Modbus reloading" in caplog.text + + +@pytest.mark.parametrize("do_config", [{}]) +async def test_integration_reload_failed(hass, caplog, mock_modbus) -> None: + """Run test for integration connect failure on reload.""" + caplog.set_level(logging.INFO) + caplog.clear() + + yaml_path = get_fixture_path("configuration.yaml", "modbus") + with mock.patch.object( + hass_config, "YAML_CONFIG_FILE", yaml_path + ), mock.patch.object(mock_modbus, "connect", side_effect=ModbusException("error")): + await hass.services.async_call(DOMAIN, SERVICE_RELOAD, blocking=True) + await hass.async_block_till_done() + + assert "Modbus reloading" in caplog.text + assert "connect failed, retry in pymodbus" in caplog.text