mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
chore: mv bot fixture
This commit is contained in:
parent
b364654a08
commit
c7bb528cd9
4 changed files with 17 additions and 25 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue