aiogram/tests/test_dispatcher.py
deepsource-autofix[bot] af4ceef153
Format code with black, autopep8 and isort
This commit fixes the style issues introduced in dd50a9b according to the output
from black, autopep8 and isort.

Details: 4e472085-2e87-4f61-b7a1-ed208506962f/
2020-11-08 21:49:34 +00:00

36 lines
926 B
Python

import pytest
from aiogram import Bot, Dispatcher
pytestmark = pytest.mark.asyncio
@pytest.yield_fixture()
async def bot(event_loop):
""" Bot fixture """
_bot = Bot(token="123456789:AABBCCDDEEFFaabbccddeeff-1234567890",
loop=event_loop)
yield _bot
await _bot.close()
class TestDispatcherInit:
async def test_successful_init(self, bot):
"""
Success __init__ case
:param bot: bot instance
:type bot: Bot
"""
dp = Dispatcher(bot=bot)
if not isinstance(dp, Dispatcher):
raise AssertionError
@pytest.mark.parametrize("bot_instance", [None, Bot, 123, "abc"])
async def test_wrong_bot_instance(self, bot_instance):
"""
User provides wrong data to 'bot' argument.
:return: TypeError with reason
"""
with pytest.raises(TypeError):
_ = Dispatcher(bot=bot_instance)