Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't reproduce simple example from README.md #16

Open
555Russich opened this issue Jun 10, 2023 · 1 comment
Open

Can't reproduce simple example from README.md #16

555Russich opened this issue Jun 10, 2023 · 1 comment

Comments

@555Russich
Copy link

Just copied 2 peaces of code from README.md in 2 files: bot.py and test.py.
Full traceback:

test.py::test_echo FAILED                                                [100%]
test.py:9 (test_echo)
@pytest.mark.asyncio
    async def test_echo():
        request = MockedBot(MessageHandler(echo))
>       calls = await request.query(message=MESSAGE.as_object(text="Hello, Bot!"))

test.py:13: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
venv/lib/python3.11/site-packages/aiogram_tests/requester.py:52: in query
    await self._handler(*args, **kwargs)
venv/lib/python3.11/site-packages/aiogram_tests/handler/handler.py:53: in __call__
    await self.feed_update(*args, **kwargs)
venv/lib/python3.11/site-packages/aiogram_tests/handler/handler.py:95: in feed_update
    await self.dp.feed_update(self.bot, types.Update(update_id=12345678, message=message))
venv/lib/python3.11/site-packages/aiogram/dispatcher/dispatcher.py:146: in feed_update
    response = await self.update.wrap_outer_middleware(
venv/lib/python3.11/site-packages/aiogram/dispatcher/middlewares/error.py:25: in __call__
    return await handler(event, data)
venv/lib/python3.11/site-packages/aiogram/dispatcher/middlewares/user_context.py:23: in __call__
    return await handler(event, data)
/usr/local/lib/python3.11/contextlib.py:222: in __aexit__
    await self.gen.athrow(typ, value, traceback)
venv/lib/python3.11/site-packages/aiogram/fsm/storage/memory.py:57: in lock
    yield
venv/lib/python3.11/site-packages/aiogram/fsm/middleware.py:39: in __call__
    return await handler(event, data)
venv/lib/python3.11/site-packages/aiogram/dispatcher/event/telegram.py:123: in trigger
    return await wrapped_inner(event, kwargs)
venv/lib/python3.11/site-packages/aiogram/dispatcher/event/handler.py:42: in call
    return await wrapped()
venv/lib/python3.11/site-packages/aiogram/dispatcher/dispatcher.py:264: in _listen_update
    return await self.propagate_event(update_type=update_type, event=event, **kwargs)
venv/lib/python3.11/site-packages/aiogram/dispatcher/router.py:115: in propagate_event
    return await observer.wrap_outer_middleware(_wrapped, event=event, data=kwargs)
venv/lib/python3.11/site-packages/aiogram/dispatcher/router.py:111: in _wrapped
    return await self._propagate_event(
venv/lib/python3.11/site-packages/aiogram/dispatcher/router.py:124: in _propagate_event
    response = await observer.trigger(event, **kwargs)
venv/lib/python3.11/site-packages/aiogram/dispatcher/event/telegram.py:123: in trigger
    return await wrapped_inner(event, kwargs)
venv/lib/python3.11/site-packages/aiogram/dispatcher/event/handler.py:42: in call
    return await wrapped()
bot.py:11: in echo
    await message.answer(message.text)
venv/lib/python3.11/site-packages/aiogram/methods/base.py:89: in emit
    return await bot(self)
venv/lib/python3.11/site-packages/aiogram_tests/mocked_bot.py:94: in __call__
    return await super().__call__(method, request_timeout)
venv/lib/python3.11/site-packages/aiogram/client/bot.py:374: in __call__
    return await self.session(self, method, timeout=request_timeout)
venv/lib/python3.11/site-packages/aiogram/client/session/base.py:194: in __call__
    return cast(TelegramType, await middleware(bot, method))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <aiogram_tests.mocked_bot.MockedSession object at 0x7f9343cbc7d0>
bot = <aiogram_tests.mocked_bot.MockedBot object at 0x7f9343cbc710>
method = SendMessage(chat_id=12345678, text='Hello, Bot!', message_thread_id=None, parse_mode=sentinel.UNSET, entities=None, di...notification=None, protect_content=None, reply_to_message_id=None, allow_sending_without_reply=None, reply_markup=None)
timeout = None

    async def make_request(
        self, bot: Bot, method: TelegramMethod[TelegramType], timeout: Optional[int] = UNSET
    ) -> TelegramType:
        self.closed = False
        self.requests.append(method.build_request(bot))
>       response: Response[TelegramType] = self.responses.pop()
E       IndexError: pop from an empty deque

venv/lib/python3.11/site-packages/aiogram_tests/mocked_bot.py:44: IndexError


============================== 1 failed in 0.54s ===============================

Process finished with exit code 1
@Aragosu
Copy link

Aragosu commented Feb 8, 2024

Привет, у меня аналогичный кейс, как в итоге можно решить проблему?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants