From 8c7ba11493ff6ecb95561f324bdb2506da263afe Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sun, 15 Jun 2025 10:23:17 +0200 Subject: [PATCH] Fix telegram_bot RuntimeWarning in tests (#146781) --- .../components/telegram_bot/test_config_flow.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/components/telegram_bot/test_config_flow.py b/tests/components/telegram_bot/test_config_flow.py index 47b6d99b9ce..0287ccc5dfa 100644 --- a/tests/components/telegram_bot/test_config_flow.py +++ b/tests/components/telegram_bot/test_config_flow.py @@ -1,6 +1,6 @@ """Config flow tests for the Telegram Bot integration.""" -from unittest.mock import patch +from unittest.mock import AsyncMock, patch from telegram import ChatFullInfo, User from telegram.constants import AccentColor @@ -305,10 +305,19 @@ async def test_reauth_flow( # test: valid - with patch( - "homeassistant.components.telegram_bot.config_flow.Bot.get_me", - return_value=User(123456, "Testbot", True), + with ( + patch( + "homeassistant.components.telegram_bot.config_flow.Bot.get_me", + return_value=User(123456, "Testbot", True), + ), + patch( + "homeassistant.components.telegram_bot.webhooks.PushBot", + ) as mock_pushbot, ): + mock_pushbot.return_value.start_application = AsyncMock() + mock_pushbot.return_value.register_webhook = AsyncMock() + mock_pushbot.return_value.shutdown = AsyncMock() + result = await hass.config_entries.flow.async_configure( result["flow_id"], {CONF_API_KEY: "new mock api key"},