mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 10:11:52 +00:00
refactor: remove redundant pytest marks (#654)
This commit is contained in:
parent
fff33e4ac9
commit
f2f276b8cf
111 changed files with 221 additions and 256 deletions
|
|
@ -38,6 +38,8 @@ except ImportError:
|
|||
from unittest.mock import AsyncMock as CoroutineMock # type: ignore
|
||||
from unittest.mock import patch
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
async def simple_message_handler(message: Message):
|
||||
await asyncio.sleep(0.2)
|
||||
|
|
@ -82,7 +84,6 @@ class TestDispatcher:
|
|||
dp._parent_router = Router()
|
||||
assert dp.parent_router is None
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("isolate_events", (True, False))
|
||||
async def test_feed_update(self, isolate_events):
|
||||
dp = Dispatcher(isolate_events=isolate_events)
|
||||
|
|
@ -112,7 +113,6 @@ class TestDispatcher:
|
|||
results_count += 1
|
||||
assert result == "test"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_feed_raw_update(self):
|
||||
dp = Dispatcher()
|
||||
bot = Bot("42:TEST")
|
||||
|
|
@ -137,7 +137,6 @@ class TestDispatcher:
|
|||
)
|
||||
assert result == "test"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_listen_updates(self, bot: MockedBot):
|
||||
dispatcher = Dispatcher()
|
||||
bot.add_result_for(
|
||||
|
|
@ -151,7 +150,6 @@ class TestDispatcher:
|
|||
break
|
||||
assert index == 42
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_listen_update_with_error(self, bot: MockedBot):
|
||||
dispatcher = Dispatcher()
|
||||
listen = dispatcher._listen_updates(bot=bot)
|
||||
|
|
@ -166,7 +164,6 @@ class TestDispatcher:
|
|||
assert isinstance(await anext(listen), Update)
|
||||
assert mocked_asleep.awaited
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_silent_call_request(self, bot: MockedBot, caplog):
|
||||
dispatcher = Dispatcher()
|
||||
bot.add_result_for(SendMessage, ok=False, error_code=400, description="Kaboom")
|
||||
|
|
@ -175,14 +172,12 @@ class TestDispatcher:
|
|||
assert len(log_records) == 1
|
||||
assert "Failed to make answer" in log_records[0]
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_process_update_empty(self, bot: MockedBot):
|
||||
dispatcher = Dispatcher()
|
||||
|
||||
result = await dispatcher._process_update(bot=bot, update=Update(update_id=42))
|
||||
assert not result
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_process_update_handled(self, bot: MockedBot):
|
||||
dispatcher = Dispatcher()
|
||||
|
||||
|
|
@ -192,7 +187,6 @@ class TestDispatcher:
|
|||
|
||||
assert await dispatcher._process_update(bot=bot, update=Update(update_id=42))
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize(
|
||||
"event_type,update,has_chat,has_user",
|
||||
[
|
||||
|
|
@ -448,14 +442,12 @@ class TestDispatcher:
|
|||
assert result["event_router"] == router
|
||||
assert result["test"] == "PASS"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_listen_unknown_update(self):
|
||||
dp = Dispatcher()
|
||||
|
||||
with pytest.raises(SkipHandler):
|
||||
await dp._listen_update(Update(update_id=42))
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_listen_unhandled_update(self):
|
||||
dp = Dispatcher()
|
||||
observer = dp.observers["message"]
|
||||
|
|
@ -485,7 +477,6 @@ class TestDispatcher:
|
|||
)
|
||||
assert response is UNHANDLED
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_nested_router_listen_update(self):
|
||||
dp = Dispatcher()
|
||||
router0 = Router()
|
||||
|
|
@ -514,7 +505,6 @@ class TestDispatcher:
|
|||
assert result["event_router"] == router1
|
||||
assert result["test"] == "PASS"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_nested_router_middleware_resolution(self, bot: MockedBot):
|
||||
counter = Counter()
|
||||
|
||||
|
|
@ -558,7 +548,6 @@ class TestDispatcher:
|
|||
assert counter["child.middleware"] == 1
|
||||
assert counter["child.handler"] == 1
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_process_update_call_request(self, bot: MockedBot):
|
||||
dispatcher = Dispatcher()
|
||||
|
||||
|
|
@ -576,7 +565,6 @@ class TestDispatcher:
|
|||
print(result)
|
||||
mocked_silent_call_request.assert_awaited()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_process_update_exception(self, bot: MockedBot, caplog):
|
||||
dispatcher = Dispatcher()
|
||||
|
||||
|
|
@ -590,7 +578,6 @@ class TestDispatcher:
|
|||
assert "Cause exception while process update" in log_records[0]
|
||||
|
||||
@pytest.mark.parametrize("as_task", [True, False])
|
||||
@pytest.mark.asyncio
|
||||
async def test_polling(self, bot: MockedBot, as_task: bool):
|
||||
dispatcher = Dispatcher()
|
||||
|
||||
|
|
@ -609,7 +596,6 @@ class TestDispatcher:
|
|||
else:
|
||||
mocked_process_update.assert_awaited()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_exception_handler_catch_exceptions(self):
|
||||
dp = Dispatcher()
|
||||
router = Router()
|
||||
|
|
@ -651,7 +637,6 @@ class TestDispatcher:
|
|||
assert isinstance(response, CustomException)
|
||||
assert str(response) == "KABOOM"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_start_polling(self, bot: MockedBot):
|
||||
dispatcher = Dispatcher()
|
||||
bot.add_result_for(
|
||||
|
|
@ -685,7 +670,6 @@ class TestDispatcher:
|
|||
dispatcher.run_polling(bot)
|
||||
patched_start_polling.assert_awaited_once()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_feed_webhook_update_fast_process(self, bot: MockedBot):
|
||||
dispatcher = Dispatcher()
|
||||
dispatcher.message.register(simple_message_handler)
|
||||
|
|
@ -695,7 +679,6 @@ class TestDispatcher:
|
|||
assert response["method"] == "sendMessage"
|
||||
assert response["text"] == "ok"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_feed_webhook_update_slow_process(self, bot: MockedBot, recwarn):
|
||||
warnings.simplefilter("always")
|
||||
|
||||
|
|
@ -711,7 +694,6 @@ class TestDispatcher:
|
|||
await asyncio.sleep(0.5)
|
||||
mocked_silent_call_request.assert_awaited()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_feed_webhook_update_fast_process_error(self, bot: MockedBot, caplog):
|
||||
warnings.simplefilter("always")
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ except ImportError:
|
|||
from unittest.mock import AsyncMock as CoroutineMock # type: ignore
|
||||
from unittest.mock import patch
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
async def my_handler(value: str, index: int = 0) -> Any:
|
||||
return value
|
||||
|
|
@ -39,7 +41,6 @@ class TestEventObserver:
|
|||
assert registered_handler.callback == wrapped_handler
|
||||
assert not registered_handler.filters
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_trigger(self):
|
||||
observer = EventObserver()
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ from aiogram.dispatcher.filters.base import BaseFilter
|
|||
from aiogram.dispatcher.handler.base import BaseHandler
|
||||
from aiogram.types import Update
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
def callback1(foo: int, bar: int, baz: int):
|
||||
return locals()
|
||||
|
|
@ -126,14 +128,12 @@ class TestCallableMixin:
|
|||
obj = CallableMixin(callback)
|
||||
assert obj._prepare_kwargs(kwargs) == result
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_sync_call(self):
|
||||
obj = CallableMixin(callback1)
|
||||
|
||||
result = await obj.call(foo=42, bar="test", baz="fuz", spam=True)
|
||||
assert result == {"foo": 42, "bar": "test", "baz": "fuz"}
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_async_call(self):
|
||||
obj = CallableMixin(callback2)
|
||||
|
||||
|
|
@ -154,14 +154,12 @@ async def simple_handler(*args, **kwargs):
|
|||
|
||||
|
||||
class TestHandlerObject:
|
||||
@pytest.mark.asyncio
|
||||
async def test_check_with_bool_result(self):
|
||||
handler = HandlerObject(simple_handler, [FilterObject(lambda value: True)] * 3)
|
||||
result, data = await handler.check(42, foo=True)
|
||||
assert result
|
||||
assert data == {"foo": True}
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_check_with_dict_result(self):
|
||||
handler = HandlerObject(
|
||||
simple_handler,
|
||||
|
|
@ -176,7 +174,6 @@ class TestHandlerObject:
|
|||
assert result
|
||||
assert data == {"foo": True, "test0": "ok", "test1": "ok", "test2": "ok"}
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_check_with_combined_result(self):
|
||||
handler = HandlerObject(
|
||||
simple_handler,
|
||||
|
|
@ -186,13 +183,11 @@ class TestHandlerObject:
|
|||
assert result
|
||||
assert data == {"foo": True, "test": 42}
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_check_rejected(self):
|
||||
handler = HandlerObject(simple_handler, [FilterObject(lambda value: False)])
|
||||
result, data = await handler.check(42, foo=True)
|
||||
assert not result
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_check_partial_rejected(self):
|
||||
handler = HandlerObject(
|
||||
simple_handler, [FilterObject(lambda value: True), FilterObject(lambda value: False)]
|
||||
|
|
@ -200,7 +195,6 @@ class TestHandlerObject:
|
|||
result, data = await handler.check(42, foo=True)
|
||||
assert not result
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_class_based_handler(self):
|
||||
class MyHandler(BaseHandler):
|
||||
event: Update
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@ from aiogram.dispatcher.filters.base import BaseFilter
|
|||
from aiogram.dispatcher.router import Router
|
||||
from aiogram.types import Chat, Message, User
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
# TODO: Test middlewares in routers tree
|
||||
|
||||
|
||||
|
|
@ -138,7 +141,6 @@ class TestTelegramEventObserver:
|
|||
assert len(observer.handlers) == 1
|
||||
assert observer.handlers[0].callback == my_handler
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_trigger(self):
|
||||
router = Router(use_builtin_filters=False)
|
||||
observer = router.message
|
||||
|
|
@ -178,7 +180,6 @@ class TestTelegramEventObserver:
|
|||
assert registered_handler.callback == wrapped_handler
|
||||
assert len(registered_handler.filters) == len(filters)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_trigger_right_context_in_handlers(self):
|
||||
router = Router(use_builtin_filters=False)
|
||||
observer = router.message
|
||||
|
|
@ -250,7 +251,6 @@ class TestTelegramEventObserver:
|
|||
assert len(router.message._handler.filters) == 1
|
||||
assert router.message._handler.filters[0].callback is my_filter
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_global_filter(self):
|
||||
r1 = Router()
|
||||
r2 = Router()
|
||||
|
|
@ -265,7 +265,6 @@ class TestTelegramEventObserver:
|
|||
assert await r1.message.trigger(None) is REJECTED
|
||||
assert await r2.message.trigger(None) is None
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_global_filter_in_nested_router(self):
|
||||
r1 = Router()
|
||||
r2 = Router()
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ except ImportError:
|
|||
from unittest.mock import AsyncMock as CoroutineMock # type: ignore
|
||||
from unittest.mock import patch
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
class MyFilter(BaseFilter):
|
||||
foo: str
|
||||
|
|
@ -19,7 +21,6 @@ class MyFilter(BaseFilter):
|
|||
|
||||
|
||||
class TestBaseFilter:
|
||||
@pytest.mark.asyncio
|
||||
async def test_awaitable(self):
|
||||
my_filter = MyFilter(foo="bar")
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ from aiogram import F
|
|||
from aiogram.dispatcher.filters.callback_data import CallbackData
|
||||
from aiogram.types import CallbackQuery, User
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
class MyIntEnum(Enum):
|
||||
FOO = auto()
|
||||
|
|
@ -163,7 +165,6 @@ class TestCallbackDataFilter:
|
|||
["test:test:", None, False],
|
||||
],
|
||||
)
|
||||
@pytest.mark.asyncio
|
||||
async def test_call(self, query, rule, result):
|
||||
callback_query = CallbackQuery(
|
||||
id="1",
|
||||
|
|
@ -175,7 +176,6 @@ class TestCallbackDataFilter:
|
|||
filter_object = MyCallback.filter(rule)
|
||||
assert await filter_object(callback_query) == result
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_invalid_call(self):
|
||||
filter_object = MyCallback.filter(F.test)
|
||||
assert not await filter_object(User(id=42, is_bot=False, first_name="test"))
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ from aiogram.methods import GetMe
|
|||
from aiogram.types import Chat, Message, User
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
class TestCommandFilter:
|
||||
def test_convert_to_list(self):
|
||||
|
|
@ -52,7 +54,6 @@ class TestCommandFilter:
|
|||
["/start dGVzdA", CommandStart(deep_link=True, deep_link_encoded=True), True],
|
||||
],
|
||||
)
|
||||
@pytest.mark.asyncio
|
||||
async def test_parse_command(self, bot: MockedBot, text: str, result: bool, command: Command):
|
||||
# TODO: test ignore case
|
||||
# TODO: test ignore mention
|
||||
|
|
@ -68,7 +69,6 @@ class TestCommandFilter:
|
|||
response = await command(message, bot)
|
||||
assert bool(response) is result
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize(
|
||||
"message,result",
|
||||
[
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ from pydantic import ValidationError
|
|||
from aiogram.dispatcher.filters import ContentTypesFilter
|
||||
from aiogram.types import ContentType, Message
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
@dataclass
|
||||
class MinimalMessage:
|
||||
|
|
@ -14,7 +16,6 @@ class MinimalMessage:
|
|||
|
||||
|
||||
class TestContentTypesFilter:
|
||||
@pytest.mark.asyncio
|
||||
async def test_validator_empty(self):
|
||||
filter_ = ContentTypesFilter()
|
||||
assert not filter_.content_types
|
||||
|
|
@ -53,7 +54,6 @@ class TestContentTypesFilter:
|
|||
[[ContentType.ANY, ContentType.PHOTO, ContentType.DOCUMENT], ContentType.TEXT, True],
|
||||
],
|
||||
)
|
||||
@pytest.mark.asyncio
|
||||
async def test_call(self, values, content_type, result):
|
||||
filter_ = ContentTypesFilter(content_types=values)
|
||||
assert await filter_(cast(Message, MinimalMessage(content_type=content_type))) == result
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import pytest
|
|||
|
||||
from aiogram.dispatcher.filters import ExceptionMessageFilter, ExceptionTypeFilter
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
class TestExceptionMessageFilter:
|
||||
@pytest.mark.parametrize("value", ["value", re.compile("value")])
|
||||
|
|
@ -11,7 +13,6 @@ class TestExceptionMessageFilter:
|
|||
obj = ExceptionMessageFilter(pattern=value)
|
||||
assert isinstance(obj.pattern, re.Pattern)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_match(self):
|
||||
obj = ExceptionMessageFilter(pattern="KABOOM")
|
||||
|
||||
|
|
@ -32,7 +33,6 @@ class MyAnotherException(MyException):
|
|||
|
||||
|
||||
class TestExceptionTypeFilter:
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize(
|
||||
"exception,value",
|
||||
[
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ from aiogram.dispatcher.filters import BUILTIN_FILTERS
|
|||
from aiogram.dispatcher.filters.text import Text
|
||||
from aiogram.types import CallbackQuery, Chat, InlineQuery, Message, Poll, PollOption, User
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
class TestText:
|
||||
def test_default_for_observer(self):
|
||||
|
|
@ -240,7 +242,6 @@ class TestText:
|
|||
["text", True, ["question", "another question"], object(), False],
|
||||
],
|
||||
)
|
||||
@pytest.mark.asyncio
|
||||
async def test_check_text(self, argument, ignore_case, input_value, result, update_type):
|
||||
text = Text(**{argument: input_value}, text_ignore_case=ignore_case)
|
||||
assert await text(obj=update_type) is result
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ import pytest
|
|||
from aiogram.dispatcher.fsm.storage.redis import RedisStorage
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
@pytest.mark.redis
|
||||
class TestRedisStorage:
|
||||
|
|
@ -15,7 +17,6 @@ class TestRedisStorage:
|
|||
[lambda bot: "kaboom", "fsm:kaboom:-1:2"],
|
||||
],
|
||||
)
|
||||
@pytest.mark.asyncio
|
||||
async def test_generate_key(self, bot: MockedBot, redis_server, prefix_bot, result):
|
||||
storage = RedisStorage.from_url(redis_server, prefix_bot=prefix_bot)
|
||||
assert storage.generate_key(bot, -1, 2) == result
|
||||
|
|
|
|||
|
|
@ -3,19 +3,19 @@ import pytest
|
|||
from aiogram.dispatcher.fsm.storage.base import BaseStorage
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"storage",
|
||||
[pytest.lazy_fixture("redis_storage"), pytest.lazy_fixture("memory_storage")],
|
||||
)
|
||||
class TestStorages:
|
||||
@pytest.mark.asyncio
|
||||
async def test_lock(self, bot: MockedBot, storage: BaseStorage):
|
||||
# TODO: ?!?
|
||||
async with storage.lock(bot=bot, chat_id=-42, user_id=42):
|
||||
assert True, "You are kidding me?"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_set_state(self, bot: MockedBot, storage: BaseStorage):
|
||||
assert await storage.get_state(bot=bot, chat_id=-42, user_id=42) is None
|
||||
|
||||
|
|
@ -24,7 +24,6 @@ class TestStorages:
|
|||
await storage.set_state(bot=bot, chat_id=-42, user_id=42, state=None)
|
||||
assert await storage.get_state(bot=bot, chat_id=-42, user_id=42) is None
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_set_data(self, bot: MockedBot, storage: BaseStorage):
|
||||
assert await storage.get_data(bot=bot, chat_id=-42, user_id=42) == {}
|
||||
|
||||
|
|
@ -33,7 +32,6 @@ class TestStorages:
|
|||
await storage.set_data(bot=bot, chat_id=-42, user_id=42, data={})
|
||||
assert await storage.get_data(bot=bot, chat_id=-42, user_id=42) == {}
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_update_data(self, bot: MockedBot, storage: BaseStorage):
|
||||
assert await storage.get_data(bot=bot, chat_id=-42, user_id=42) == {}
|
||||
assert await storage.update_data(
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ from aiogram.dispatcher.fsm.context import FSMContext
|
|||
from aiogram.dispatcher.fsm.storage.memory import MemoryStorage
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def state(bot: MockedBot):
|
||||
|
|
@ -15,7 +17,6 @@ def state(bot: MockedBot):
|
|||
|
||||
|
||||
class TestFSMContext:
|
||||
@pytest.mark.asyncio
|
||||
async def test_address_mapping(self, bot: MockedBot):
|
||||
storage = MemoryStorage()
|
||||
ctx = storage.storage[bot][-42][42]
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ from aiogram.dispatcher.event.handler import HandlerObject
|
|||
from aiogram.dispatcher.handler.base import BaseHandler
|
||||
from aiogram.types import Chat, Message, Update
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
class MyHandler(BaseHandler):
|
||||
async def handle(self) -> Any:
|
||||
|
|
@ -18,7 +20,6 @@ class MyHandler(BaseHandler):
|
|||
|
||||
|
||||
class TestBaseClassBasedHandler:
|
||||
@pytest.mark.asyncio
|
||||
async def test_base_handler(self):
|
||||
event = Update(update_id=42)
|
||||
handler = MyHandler(event=event, key=42)
|
||||
|
|
@ -28,7 +29,6 @@ class TestBaseClassBasedHandler:
|
|||
assert not hasattr(handler, "filters")
|
||||
assert await handler == 42
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_bot_from_context(self):
|
||||
event = Update(update_id=42)
|
||||
handler = MyHandler(event=event, key=42)
|
||||
|
|
@ -40,7 +40,6 @@ class TestBaseClassBasedHandler:
|
|||
Bot.set_current(bot)
|
||||
assert handler.bot == bot
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_bot_from_data(self):
|
||||
event = Update(update_id=42)
|
||||
bot = Bot("42:TEST")
|
||||
|
|
@ -59,7 +58,6 @@ class TestBaseClassBasedHandler:
|
|||
assert handler.event == event
|
||||
assert handler.update == update
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_wrapped_handler(self):
|
||||
# wrap the handler on dummy function
|
||||
handler = wraps(MyHandler)(lambda: None)
|
||||
|
|
|
|||
|
|
@ -5,9 +5,10 @@ import pytest
|
|||
from aiogram.dispatcher.handler import CallbackQueryHandler
|
||||
from aiogram.types import CallbackQuery, User
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
class TestCallbackQueryHandler:
|
||||
@pytest.mark.asyncio
|
||||
async def test_attributes_aliases(self):
|
||||
event = CallbackQuery(
|
||||
id="chosen",
|
||||
|
|
|
|||
|
|
@ -6,9 +6,10 @@ import pytest
|
|||
from aiogram.dispatcher.handler.chat_member import ChatMemberHandler
|
||||
from aiogram.types import Chat, ChatMemberMember, ChatMemberUpdated, User
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
class TestChatMemberUpdated:
|
||||
@pytest.mark.asyncio
|
||||
async def test_attributes_aliases(self):
|
||||
event = ChatMemberUpdated(
|
||||
chat=Chat(id=42, type="private"),
|
||||
|
|
|
|||
|
|
@ -5,9 +5,10 @@ import pytest
|
|||
from aiogram.dispatcher.handler import ChosenInlineResultHandler
|
||||
from aiogram.types import ChosenInlineResult, User
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
class TestChosenInlineResultHandler:
|
||||
@pytest.mark.asyncio
|
||||
async def test_attributes_aliases(self):
|
||||
event = ChosenInlineResult(
|
||||
result_id="chosen",
|
||||
|
|
|
|||
|
|
@ -4,9 +4,10 @@ import pytest
|
|||
|
||||
from aiogram.dispatcher.handler import ErrorHandler
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
class TestErrorHandler:
|
||||
@pytest.mark.asyncio
|
||||
async def test_extensions(self):
|
||||
event = KeyError("kaboom")
|
||||
|
||||
|
|
|
|||
|
|
@ -5,9 +5,10 @@ import pytest
|
|||
from aiogram.dispatcher.handler import InlineQueryHandler
|
||||
from aiogram.types import InlineQuery, User
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
class TestCallbackQueryHandler:
|
||||
@pytest.mark.asyncio
|
||||
async def test_attributes_aliases(self):
|
||||
event = InlineQuery(
|
||||
id="query",
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ from aiogram.dispatcher.filters import CommandObject
|
|||
from aiogram.dispatcher.handler.message import MessageHandler, MessageHandlerCommandMixin
|
||||
from aiogram.types import Chat, Message, User
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
class MyHandler(MessageHandler):
|
||||
async def handle(self) -> Any:
|
||||
|
|
@ -14,7 +16,6 @@ class MyHandler(MessageHandler):
|
|||
|
||||
|
||||
class TestClassBasedMessageHandler:
|
||||
@pytest.mark.asyncio
|
||||
async def test_message_handler(self):
|
||||
event = Message(
|
||||
message_id=42,
|
||||
|
|
|
|||
|
|
@ -5,9 +5,10 @@ import pytest
|
|||
from aiogram.dispatcher.handler import PollHandler
|
||||
from aiogram.types import Poll, PollOption
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
class TestShippingQueryHandler:
|
||||
@pytest.mark.asyncio
|
||||
async def test_attributes_aliases(self):
|
||||
event = Poll(
|
||||
id="query",
|
||||
|
|
|
|||
|
|
@ -5,9 +5,10 @@ import pytest
|
|||
from aiogram.dispatcher.handler import PreCheckoutQueryHandler
|
||||
from aiogram.types import PreCheckoutQuery, User
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
class TestPreCheckoutQueryHandler:
|
||||
@pytest.mark.asyncio
|
||||
async def test_attributes_aliases(self):
|
||||
event = PreCheckoutQuery(
|
||||
id="query",
|
||||
|
|
|
|||
|
|
@ -5,9 +5,10 @@ import pytest
|
|||
from aiogram.dispatcher.handler import ShippingQueryHandler
|
||||
from aiogram.types import ShippingAddress, ShippingQuery, User
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
class TestShippingQueryHandler:
|
||||
@pytest.mark.asyncio
|
||||
async def test_attributes_aliases(self):
|
||||
event = ShippingQuery(
|
||||
id="query",
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from aiogram.dispatcher.event.bases import UNHANDLED, SkipHandler, skip
|
|||
from aiogram.dispatcher.router import Router
|
||||
from aiogram.utils.warnings import CodeHasNoEffect
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
importable_router = Router()
|
||||
|
||||
|
||||
|
|
@ -73,7 +74,6 @@ class TestRouter:
|
|||
assert router.observers["pre_checkout_query"] == router.pre_checkout_query
|
||||
assert router.observers["poll"] == router.poll
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_emit_startup(self):
|
||||
router1 = Router()
|
||||
router2 = Router()
|
||||
|
|
@ -95,7 +95,6 @@ class TestRouter:
|
|||
await router1.emit_startup()
|
||||
assert results == [2, 1, 2]
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_emit_shutdown(self):
|
||||
router1 = Router()
|
||||
router2 = Router()
|
||||
|
|
@ -123,7 +122,6 @@ class TestRouter:
|
|||
with pytest.raises(SkipHandler, match="KABOOM"):
|
||||
skip("KABOOM")
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_global_filter_in_nested_router(self):
|
||||
r1 = Router()
|
||||
r2 = Router()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue