chore: mv bot fixture

This commit is contained in:
Oleg A 2022-01-10 11:29:42 +03:00
parent b364654a08
commit c7bb528cd9
4 changed files with 17 additions and 25 deletions

View file

@ -1,7 +1,12 @@
import asyncio
import aioredis
import pytest
from _pytest.config import UsageError
from aiogram import Bot
from . import TOKEN
try:
import aioredis.util
except ImportError:
@ -72,3 +77,14 @@ def redis_options(request):
raise UsageError(f"Invalid redis URI {redis_uri!r}: {e}")
raise UsageError("Unsupported aioredis version")
@pytest.fixture(name='bot')
async def bot_fixture():
"""Bot fixture."""
bot = Bot(TOKEN)
yield bot
session = await bot.get_session()
if session and not session.closed:
await session.close()
await asyncio.sleep(0.2)

View file

@ -6,14 +6,6 @@ from . import FakeTelegram, TOKEN, BOT_ID
pytestmark = pytest.mark.asyncio
@pytest.fixture(name='bot')
async def bot_fixture():
""" Bot fixture """
_bot = Bot(TOKEN, parse_mode=types.ParseMode.MARKDOWN_V2)
yield _bot
await _bot.close()
async def test_get_me(bot: Bot):
""" getMe method test """
from .types.dataset import USER

View file

@ -5,14 +5,6 @@ from aiogram import Dispatcher, Bot
pytestmark = pytest.mark.asyncio
@pytest.fixture(name='bot')
async def bot_fixture():
""" Bot fixture """
_bot = Bot(token='123456789:AABBCCDDEEFFaabbccddeeff-1234567890')
yield _bot
await _bot.close()
class TestDispatcherInit:
async def test_successful_init(self, bot):
"""

View file

@ -8,16 +8,8 @@ from . import FakeTelegram, TOKEN
pytestmark = pytest.mark.asyncio
@pytest.fixture(name='bot')
async def bot_fixture():
""" Bot fixture """
_bot = Bot(TOKEN, parse_mode=types.ParseMode.HTML)
yield _bot
await _bot.close()
@pytest.fixture()
async def message(bot):
async def message(bot: Bot):
"""
Message fixture
:param bot: Telegram bot fixture