Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Stabilize Some Concurrency Usages in Test Suite #4360

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

Merged
merged 2 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions tests/test_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2368,11 +2368,15 @@ async def test_delete_message_old_message(self, bot, chat_id):
# 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
Expand Down Expand Up @@ -3915,7 +3919,7 @@ async def test_copy_messages(self, bot, chat_id):
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)

Expand Down
10 changes: 10 additions & 0 deletions tests/test_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@ async def test_max_message_length(self, bot, chat_id):
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)
Expand All @@ -247,6 +252,11 @@ async def test_max_caption_length(self, bot, chat_id):
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