mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 02:03:04 +00:00
Removed the use of the context instance (Bot.get_current) from all placements that were used previously. (#1230)
* Removed the use of the context instance (Bot.get_current) from all placements that were used previously. * Fixed tests * Added changelog * Change category
This commit is contained in:
parent
479e302cba
commit
2ecf9cefd7
11 changed files with 45 additions and 49 deletions
|
|
@ -29,15 +29,17 @@ class TestBaseClassBasedHandler:
|
|||
|
||||
async def test_bot_from_context(self):
|
||||
event = Update(update_id=42)
|
||||
handler = MyHandler(event=event, key=42)
|
||||
bot = Bot("42:TEST")
|
||||
|
||||
with pytest.raises(LookupError):
|
||||
handler.bot
|
||||
|
||||
Bot.set_current(bot)
|
||||
handler = MyHandler(event=event, key=42, bot=bot)
|
||||
assert handler.bot == bot
|
||||
|
||||
async def test_bot_from_context_missing(self):
|
||||
event = Update(update_id=42)
|
||||
handler = MyHandler(event=event, key=42)
|
||||
|
||||
with pytest.raises(RuntimeError):
|
||||
handler.bot
|
||||
|
||||
async def test_bot_from_data(self):
|
||||
event = Update(update_id=42)
|
||||
bot = Bot("42:TEST")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue