mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-24 16:17:37 +01:00
Stabilize Some Flaky Tests (#4500)
This commit is contained in:
parent
79e589b39e
commit
2bc65560eb
2 changed files with 17 additions and 17 deletions
|
@ -233,7 +233,8 @@ class TestAnimationWithRequest(AnimationTestBase):
|
||||||
assert message.animation.file_unique_id
|
assert message.animation.file_unique_id
|
||||||
assert message.animation.file_name == animation.file_name
|
assert message.animation.file_name == animation.file_name
|
||||||
assert message.animation.mime_type == animation.mime_type
|
assert message.animation.mime_type == animation.mime_type
|
||||||
assert message.animation.file_size == animation.file_size
|
# TGs reported file size is not reliable
|
||||||
|
assert isinstance(message.animation.file_size, int)
|
||||||
assert message.animation.thumbnail.width == self.width
|
assert message.animation.thumbnail.width == self.width
|
||||||
assert message.animation.thumbnail.height == self.height
|
assert message.animation.thumbnail.height == self.height
|
||||||
assert message.has_protected_content
|
assert message.has_protected_content
|
||||||
|
|
|
@ -2372,15 +2372,12 @@ class TestBotWithRequest:
|
||||||
assert all("can't be forwarded" in str(exc) for exc in result)
|
assert all("can't be forwarded" in str(exc) for exc in result)
|
||||||
|
|
||||||
async def test_forward_messages(self, bot, chat_id):
|
async def test_forward_messages(self, bot, chat_id):
|
||||||
tasks = asyncio.gather(
|
# not using gather here to have deteriminically ordered message_ids
|
||||||
bot.send_message(chat_id, text="will be forwarded"),
|
msg1 = await bot.send_message(chat_id, text="will be forwarded")
|
||||||
bot.send_message(chat_id, text="will be forwarded"),
|
msg2 = await bot.send_message(chat_id, text="will be forwarded")
|
||||||
)
|
|
||||||
|
|
||||||
msg1, msg2 = await tasks
|
|
||||||
|
|
||||||
forward_messages = await bot.forward_messages(
|
forward_messages = await bot.forward_messages(
|
||||||
chat_id, from_chat_id=chat_id, message_ids=sorted((msg1.message_id, msg2.message_id))
|
chat_id, from_chat_id=chat_id, message_ids=(msg1.message_id, msg2.message_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
assert isinstance(forward_messages, tuple)
|
assert isinstance(forward_messages, tuple)
|
||||||
|
@ -3939,14 +3936,12 @@ class TestBotWithRequest:
|
||||||
assert len(message.caption_entities) == 0
|
assert len(message.caption_entities) == 0
|
||||||
|
|
||||||
async def test_copy_messages(self, bot, chat_id):
|
async def test_copy_messages(self, bot, chat_id):
|
||||||
tasks = asyncio.gather(
|
# not using gather here to have deterministically ordered message_ids
|
||||||
bot.send_message(chat_id, text="will be copied 1"),
|
msg1 = await bot.send_message(chat_id, text="will be copied 1")
|
||||||
bot.send_message(chat_id, text="will be copied 2"),
|
msg2 = await bot.send_message(chat_id, text="will be copied 2")
|
||||||
)
|
|
||||||
msg1, msg2 = await tasks
|
|
||||||
|
|
||||||
copy_messages = await bot.copy_messages(
|
copy_messages = await bot.copy_messages(
|
||||||
chat_id, from_chat_id=chat_id, message_ids=sorted((msg1.message_id, msg2.message_id))
|
chat_id, from_chat_id=chat_id, message_ids=(msg1.message_id, msg2.message_id)
|
||||||
)
|
)
|
||||||
assert isinstance(copy_messages, tuple)
|
assert isinstance(copy_messages, tuple)
|
||||||
|
|
||||||
|
@ -4059,7 +4054,7 @@ class TestBotWithRequest:
|
||||||
bot.callback_data_cache.clear_callback_data()
|
bot.callback_data_cache.clear_callback_data()
|
||||||
bot.callback_data_cache.clear_callback_queries()
|
bot.callback_data_cache.clear_callback_queries()
|
||||||
|
|
||||||
async def test_get_chat_arbitrary_callback_data(self, channel_id, cdc_bot):
|
async def test_get_chat_arbitrary_callback_data(self, chat_id, cdc_bot):
|
||||||
bot = cdc_bot
|
bot = cdc_bot
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -4068,7 +4063,7 @@ class TestBotWithRequest:
|
||||||
)
|
)
|
||||||
|
|
||||||
message = await bot.send_message(
|
message = await bot.send_message(
|
||||||
channel_id, text="get_chat_arbitrary_callback_data", reply_markup=reply_markup
|
chat_id, text="get_chat_arbitrary_callback_data", reply_markup=reply_markup
|
||||||
)
|
)
|
||||||
await message.pin()
|
await message.pin()
|
||||||
|
|
||||||
|
@ -4078,7 +4073,11 @@ class TestBotWithRequest:
|
||||||
)
|
)
|
||||||
assert data == "callback_data"
|
assert data == "callback_data"
|
||||||
|
|
||||||
cfi = await bot.get_chat(channel_id)
|
cfi = await bot.get_chat(chat_id)
|
||||||
|
|
||||||
|
if not cfi.pinned_message:
|
||||||
|
pytest.xfail("Pinning messages is not always reliable on TG")
|
||||||
|
|
||||||
assert cfi.pinned_message == message
|
assert cfi.pinned_message == message
|
||||||
assert cfi.pinned_message.reply_markup == reply_markup
|
assert cfi.pinned_message.reply_markup == reply_markup
|
||||||
assert await message.unpin() # (not placed in finally block since msg can be unbound)
|
assert await message.unpin() # (not placed in finally block since msg can be unbound)
|
||||||
|
|
Loading…
Reference in a new issue