From acbe1f81b68853dc364478f366691ed60f3faaa8 Mon Sep 17 00:00:00 2001 From: jrootjunior Date: Wed, 11 Dec 2019 15:49:42 +0200 Subject: [PATCH] Cover Dispatcher.run --- aiogram/dispatcher/dispatcher.py | 3 ++- tests/test_dispatcher/test_dispatcher.py | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/aiogram/dispatcher/dispatcher.py b/aiogram/dispatcher/dispatcher.py index eec8497e..4984b212 100644 --- a/aiogram/dispatcher/dispatcher.py +++ b/aiogram/dispatcher/dispatcher.py @@ -153,5 +153,6 @@ class Dispatcher(Router): """ try: return asyncio.run(self._run_polling(*bots, **kwargs)) - except (KeyboardInterrupt, SystemExit): # Allow to graceful shutdown + 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 a0552085..42abb826 100644 --- a/tests/test_dispatcher/test_dispatcher.py +++ b/tests/test_dispatcher/test_dispatcher.py @@ -189,6 +189,8 @@ class TestDispatcher: mocked_process_update.assert_awaited() mocked_emit_shutdown.assert_awaited() - @pytest.mark.skip - def test_run(self): - pass + def test_run(self, bot: MockedBot): + dispatcher = Dispatcher() + with patch("aiogram.dispatcher.dispatcher.Dispatcher._run_polling") as patched_run_polling: + dispatcher.run(bot) + patched_run_polling.assert_awaited_once()