mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-23 07:38:58 +01:00
Stabilize Some Concurrency Usages in Test Suite (#4360)
This commit is contained in:
parent
7a470d57c8
commit
06f1da576e
2 changed files with 19 additions and 5 deletions
|
@ -2368,11 +2368,15 @@ class TestBotWithRequest:
|
|||
# test modules. No need to duplicate here.
|
||||
|
||||
async def test_delete_messages(self, bot, chat_id):
|
||||
msg1 = await bot.send_message(chat_id, text="will be deleted")
|
||||
msg2 = await bot.send_message(chat_id, text="will be deleted")
|
||||
await asyncio.sleep(2)
|
||||
msg1, msg2 = await asyncio.gather(
|
||||
bot.send_message(chat_id, text="will be deleted"),
|
||||
bot.send_message(chat_id, text="will be deleted"),
|
||||
)
|
||||
|
||||
assert await bot.delete_messages(chat_id=chat_id, message_ids=(msg1.id, msg2.id)) is True
|
||||
assert (
|
||||
await bot.delete_messages(chat_id=chat_id, message_ids=sorted((msg1.id, msg2.id)))
|
||||
is True
|
||||
)
|
||||
|
||||
async def test_send_venue(self, bot, chat_id):
|
||||
longitude = -46.788279
|
||||
|
@ -3915,7 +3919,7 @@ class TestBotWithRequest:
|
|||
msg1, msg2 = await tasks
|
||||
|
||||
copy_messages = await bot.copy_messages(
|
||||
chat_id, from_chat_id=chat_id, message_ids=(msg1.message_id, msg2.message_id)
|
||||
chat_id, from_chat_id=chat_id, message_ids=sorted((msg1.message_id, msg2.message_id))
|
||||
)
|
||||
assert isinstance(copy_messages, tuple)
|
||||
|
||||
|
|
|
@ -234,6 +234,11 @@ class TestConstantsWithRequest:
|
|||
return_exceptions=True,
|
||||
)
|
||||
good_msg, bad_msg = await tasks
|
||||
|
||||
if isinstance(good_msg, BaseException):
|
||||
# handling xfails
|
||||
raise good_msg
|
||||
|
||||
assert good_msg.text == good_text
|
||||
assert isinstance(bad_msg, BadRequest)
|
||||
assert "Message is too long" in str(bad_msg)
|
||||
|
@ -247,6 +252,11 @@ class TestConstantsWithRequest:
|
|||
return_exceptions=True,
|
||||
)
|
||||
good_msg, bad_msg = await tasks
|
||||
|
||||
if isinstance(good_msg, BaseException):
|
||||
# handling xfails
|
||||
raise good_msg
|
||||
|
||||
assert good_msg.caption == good_caption
|
||||
assert isinstance(bad_msg, BadRequest)
|
||||
assert "Message caption is too long" in str(bad_msg)
|
||||
|
|
Loading…
Reference in a new issue