Stabilize Some Concurrency Usages in Test Suite (#4360)

This commit is contained in:
Bibo-Joshi 2024-07-10 17:11:22 +02:00 committed by GitHub
parent 7a470d57c8
commit 06f1da576e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 5 deletions

View file

@ -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)

View file

@ -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)