diff --git a/Makefile b/Makefile index 3b2f3dca..c4570330 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ .DEFAULT_GOAL := help -base_python := python3.7 +base_python := python3 py := poetry run python := $(py) python diff --git a/aiogram/dispatcher/dispatcher.py b/aiogram/dispatcher/dispatcher.py index 30255b88..d8f6b54e 100644 --- a/aiogram/dispatcher/dispatcher.py +++ b/aiogram/dispatcher/dispatcher.py @@ -151,7 +151,7 @@ class Dispatcher(Router): async for update in self._listen_updates(bot): await self.process_update(update=update, bot=bot, **kwargs) - async def _run_polling(self, *bots: Bot, **kwargs: Any) -> None: + async def start_polling(self, *bots: Bot, **kwargs: Any) -> None: """ Polling runner @@ -188,7 +188,7 @@ class Dispatcher(Router): :return: """ try: - return asyncio.run(self._run_polling(*bots, **kwargs)) + return asyncio.run(self.start_polling(*bots, **kwargs)) except (KeyboardInterrupt, SystemExit): # pragma: no cover # Allow to graceful shutdown pass diff --git a/tests/test_dispatcher/test_dispatcher.py b/tests/test_dispatcher/test_dispatcher.py index c85b288b..fd54d27c 100644 --- a/tests/test_dispatcher/test_dispatcher.py +++ b/tests/test_dispatcher/test_dispatcher.py @@ -164,7 +164,7 @@ class TestDispatcher: mocked_process_update.assert_awaited() @pytest.mark.asyncio - async def test_run_polling(self, bot: MockedBot): + async def test_start_polling(self, bot: MockedBot): dispatcher = Dispatcher() bot.add_result_for( GetMe, ok=True, result=User(id=42, is_bot=True, first_name="The bot", username="tbot") @@ -183,14 +183,14 @@ class TestDispatcher: "aiogram.dispatcher.dispatcher.Dispatcher._listen_updates" ) as patched_listen_updates: patched_listen_updates.return_value = _mock_updates() - await dispatcher._run_polling(bot) + await dispatcher.start_polling(bot) mocked_emit_startup.assert_awaited() mocked_process_update.assert_awaited() mocked_emit_shutdown.assert_awaited() - def test_run(self, bot: MockedBot): + def test_run_polling(self, bot: MockedBot): dispatcher = Dispatcher() - with patch("aiogram.dispatcher.dispatcher.Dispatcher._run_polling") as patched_run_polling: + with patch("aiogram.dispatcher.dispatcher.Dispatcher.start_polling") as patched_start_polling: dispatcher.run_polling(bot) - patched_run_polling.assert_awaited_once() + patched_start_polling.assert_awaited_once()