mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-12-22 14:35:00 +01:00
Stabilize CI (#2480)
* mark some occasionally failing tests as flaky
* fix test which was failing locally for some reason
* Don't fail tests if they've exceeded the timeout
* This reverts commit 1d0f982e95
.
* remove flaky on two tests as per review
* the end of timeout failures, hopefully.
* first run successful. Fixing pre-commit to trigger 2nd run.
This commit is contained in:
parent
3938a57542
commit
b20265819b
24 changed files with 5 additions and 193 deletions
|
@ -13,5 +13,4 @@ pytest==6.2.3
|
|||
|
||||
flaky
|
||||
beautifulsoup4
|
||||
pytest-timeout
|
||||
wheel
|
||||
|
|
|
@ -72,7 +72,6 @@ class TestAnimation:
|
|||
assert isinstance(animation.thumb, PhotoSize)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_all_args(self, bot, chat_id, animation_file, animation, thumb_file):
|
||||
message = bot.send_animation(
|
||||
chat_id,
|
||||
|
@ -98,7 +97,6 @@ class TestAnimation:
|
|||
assert message.animation.thumb.height == self.height
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_animation_custom_filename(self, bot, chat_id, animation_file, monkeypatch):
|
||||
def make_assertion(url, data, **kwargs):
|
||||
return data['animation'].filename == 'custom_filename'
|
||||
|
@ -108,7 +106,6 @@ class TestAnimation:
|
|||
assert bot.send_animation(chat_id, animation_file, filename='custom_filename')
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_get_and_download(self, bot, animation):
|
||||
new_file = bot.get_file(animation.file_id)
|
||||
|
||||
|
@ -121,7 +118,6 @@ class TestAnimation:
|
|||
assert os.path.isfile('game.gif')
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_animation_url_file(self, bot, chat_id, animation):
|
||||
message = bot.send_animation(
|
||||
chat_id=chat_id, animation=self.animation_file_url, caption=self.caption
|
||||
|
@ -141,7 +137,6 @@ class TestAnimation:
|
|||
assert message.animation.file_size == animation.file_size
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_animation_caption_entities(self, bot, chat_id, animation):
|
||||
test_string = 'Italic Bold Code'
|
||||
entities = [
|
||||
|
@ -157,7 +152,6 @@ class TestAnimation:
|
|||
assert message.caption_entities == entities
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize('default_bot', [{'parse_mode': 'Markdown'}], indirect=True)
|
||||
def test_send_animation_default_parse_mode_1(self, default_bot, chat_id, animation_file):
|
||||
test_string = 'Italic Bold Code'
|
||||
|
@ -168,7 +162,6 @@ class TestAnimation:
|
|||
assert message.caption == test_string
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize('default_bot', [{'parse_mode': 'Markdown'}], indirect=True)
|
||||
def test_send_animation_default_parse_mode_2(self, default_bot, chat_id, animation_file):
|
||||
test_markdown_string = '_Italic_ *Bold* `Code`'
|
||||
|
@ -180,7 +173,6 @@ class TestAnimation:
|
|||
assert message.caption_markdown == escape_markdown(test_markdown_string)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize('default_bot', [{'parse_mode': 'Markdown'}], indirect=True)
|
||||
def test_send_animation_default_parse_mode_3(self, default_bot, chat_id, animation_file):
|
||||
test_markdown_string = '_Italic_ *Bold* `Code`'
|
||||
|
@ -206,7 +198,6 @@ class TestAnimation:
|
|||
assert test_flag
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize(
|
||||
'default_bot,custom',
|
||||
[
|
||||
|
@ -241,7 +232,6 @@ class TestAnimation:
|
|||
)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_resend(self, bot, chat_id, animation):
|
||||
message = bot.send_animation(chat_id, animation.file_id)
|
||||
|
||||
|
@ -290,7 +280,6 @@ class TestAnimation:
|
|||
assert animation_dict['file_size'] == animation.file_size
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_error_send_empty_file(self, bot, chat_id):
|
||||
animation_file = open(os.devnull, 'rb')
|
||||
|
||||
|
@ -298,7 +287,6 @@ class TestAnimation:
|
|||
bot.send_animation(chat_id=chat_id, animation=animation_file)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_error_send_empty_file_id(self, bot, chat_id):
|
||||
with pytest.raises(TelegramError):
|
||||
bot.send_animation(chat_id=chat_id, animation='')
|
||||
|
|
|
@ -78,7 +78,6 @@ class TestAudio:
|
|||
assert audio.thumb.height == self.thumb_height
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_all_args(self, bot, chat_id, audio_file, thumb_file):
|
||||
message = bot.send_audio(
|
||||
chat_id,
|
||||
|
@ -110,7 +109,6 @@ class TestAudio:
|
|||
assert message.audio.thumb.height == self.thumb_height
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_audio_custom_filename(self, bot, chat_id, audio_file, monkeypatch):
|
||||
def make_assertion(url, data, **kwargs):
|
||||
return data['audio'].filename == 'custom_filename'
|
||||
|
@ -120,7 +118,6 @@ class TestAudio:
|
|||
assert bot.send_audio(chat_id, audio_file, filename='custom_filename')
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_get_and_download(self, bot, audio):
|
||||
new_file = bot.get_file(audio.file_id)
|
||||
|
||||
|
@ -134,7 +131,6 @@ class TestAudio:
|
|||
assert os.path.isfile('telegram.mp3')
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_mp3_url_file(self, bot, chat_id, audio):
|
||||
message = bot.send_audio(chat_id=chat_id, audio=self.audio_file_url, caption=self.caption)
|
||||
|
||||
|
@ -150,7 +146,6 @@ class TestAudio:
|
|||
assert message.audio.file_size == audio.file_size
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_resend(self, bot, chat_id, audio):
|
||||
message = bot.send_audio(chat_id=chat_id, audio=audio.file_id)
|
||||
|
||||
|
@ -165,7 +160,6 @@ class TestAudio:
|
|||
assert message
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_audio_caption_entities(self, bot, chat_id, audio):
|
||||
test_string = 'Italic Bold Code'
|
||||
entities = [
|
||||
|
@ -179,7 +173,6 @@ class TestAudio:
|
|||
assert message.caption_entities == entities
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize('default_bot', [{'parse_mode': 'Markdown'}], indirect=True)
|
||||
def test_send_audio_default_parse_mode_1(self, default_bot, chat_id, audio_file, thumb_file):
|
||||
test_string = 'Italic Bold Code'
|
||||
|
@ -190,7 +183,6 @@ class TestAudio:
|
|||
assert message.caption == test_string
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize('default_bot', [{'parse_mode': 'Markdown'}], indirect=True)
|
||||
def test_send_audio_default_parse_mode_2(self, default_bot, chat_id, audio_file, thumb_file):
|
||||
test_markdown_string = '_Italic_ *Bold* `Code`'
|
||||
|
@ -202,7 +194,6 @@ class TestAudio:
|
|||
assert message.caption_markdown == escape_markdown(test_markdown_string)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize('default_bot', [{'parse_mode': 'Markdown'}], indirect=True)
|
||||
def test_send_audio_default_parse_mode_3(self, default_bot, chat_id, audio_file, thumb_file):
|
||||
test_markdown_string = '_Italic_ *Bold* `Code`'
|
||||
|
@ -264,7 +255,6 @@ class TestAudio:
|
|||
assert audio_dict['file_name'] == audio.file_name
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_error_send_empty_file(self, bot, chat_id):
|
||||
audio_file = open(os.devnull, 'rb')
|
||||
|
||||
|
@ -272,7 +262,6 @@ class TestAudio:
|
|||
bot.send_audio(chat_id=chat_id, audio=audio_file)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_error_send_empty_file_id(self, bot, chat_id):
|
||||
with pytest.raises(TelegramError):
|
||||
bot.send_audio(chat_id=chat_id, audio='')
|
||||
|
|
|
@ -116,7 +116,6 @@ class TestBot:
|
|||
Bot(token)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_invalid_token_server_response(self, monkeypatch):
|
||||
monkeypatch.setattr('telegram.Bot._validate_token', lambda x, y: True)
|
||||
bot = Bot('12')
|
||||
|
@ -132,7 +131,6 @@ class TestBot:
|
|||
bot.send_message(123, 'text', api_kwargs={'unknown_kwarg_1': 7, 'unknown_kwarg_2': 5})
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_get_me_and_properties(self, bot):
|
||||
get_me_bot = bot.get_me()
|
||||
commands = bot.get_my_commands()
|
||||
|
@ -168,7 +166,6 @@ class TestBot:
|
|||
assert hash(a) != hash(d)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_to_dict(self, bot):
|
||||
to_dict_bot = bot.to_dict()
|
||||
|
||||
|
@ -214,7 +211,6 @@ class TestBot:
|
|||
assert check_defaults_handling(bot_method, bot)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_forward_message(self, bot, chat_id, message):
|
||||
message = bot.forward_message(chat_id, from_chat_id=chat_id, message_id=message.message_id)
|
||||
|
||||
|
@ -223,7 +219,6 @@ class TestBot:
|
|||
assert isinstance(message.forward_date, dtm.datetime)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_delete_message(self, bot, chat_id):
|
||||
message = bot.send_message(chat_id, text='will be deleted')
|
||||
time.sleep(2)
|
||||
|
@ -231,7 +226,6 @@ class TestBot:
|
|||
assert bot.delete_message(chat_id=chat_id, message_id=message.message_id) is True
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_delete_message_old_message(self, bot, chat_id):
|
||||
with pytest.raises(BadRequest):
|
||||
# Considering that the first message is old enough
|
||||
|
@ -242,7 +236,6 @@ class TestBot:
|
|||
# duplicate here.
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_venue(self, bot, chat_id):
|
||||
longitude = -46.788279
|
||||
latitude = -23.691288
|
||||
|
@ -294,7 +287,6 @@ class TestBot:
|
|||
assert message.venue.foursquare_type is None
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.xfail(raises=RetryAfter)
|
||||
@pytest.mark.skipif(
|
||||
python_implementation() == 'PyPy', reason='Unstable on pypy for some reason'
|
||||
|
@ -315,7 +307,6 @@ class TestBot:
|
|||
# TODO: Add bot to group to test polls too
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize(
|
||||
'reply_markup',
|
||||
[
|
||||
|
@ -390,7 +381,6 @@ class TestBot:
|
|||
assert message_quiz.poll.explanation_entities == explanation_entities
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(15)
|
||||
@pytest.mark.parametrize(['open_period', 'close_date'], [(5, None), (None, True)])
|
||||
def test_send_open_period(self, bot, super_group_id, open_period, close_date):
|
||||
question = 'Is this a test?'
|
||||
|
@ -423,7 +413,6 @@ class TestBot:
|
|||
assert new_message.poll.is_closed
|
||||
|
||||
@flaky(5, 1)
|
||||
@pytest.mark.timeout(20)
|
||||
def test_send_close_date_default_tz(self, tz_bot, super_group_id):
|
||||
question = 'Is this a test?'
|
||||
answers = ['Yes', 'No', 'Maybe']
|
||||
|
@ -455,7 +444,6 @@ class TestBot:
|
|||
assert new_message.poll.is_closed
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_poll_explanation_entities(self, bot, chat_id):
|
||||
test_string = 'Italic Bold Code'
|
||||
entities = [
|
||||
|
@ -477,7 +465,6 @@ class TestBot:
|
|||
assert message.poll.explanation_entities == entities
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize('default_bot', [{'parse_mode': 'Markdown'}], indirect=True)
|
||||
def test_send_poll_default_parse_mode(self, default_bot, super_group_id):
|
||||
explanation = 'Italic Bold Code'
|
||||
|
@ -528,7 +515,6 @@ class TestBot:
|
|||
assert message.poll.explanation_entities == []
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize(
|
||||
'default_bot,custom',
|
||||
[
|
||||
|
@ -570,7 +556,6 @@ class TestBot:
|
|||
)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize('emoji', Dice.ALL_EMOJI + [None])
|
||||
def test_send_dice(self, bot, chat_id, emoji):
|
||||
message = bot.send_dice(chat_id, emoji=emoji)
|
||||
|
@ -582,7 +567,6 @@ class TestBot:
|
|||
assert message.dice.emoji == emoji
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize(
|
||||
'default_bot,custom',
|
||||
[
|
||||
|
@ -613,7 +597,6 @@ class TestBot:
|
|||
default_bot.send_dice(chat_id, reply_to_message_id=reply_to_message.message_id)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize(
|
||||
'chat_action',
|
||||
[
|
||||
|
@ -857,14 +840,12 @@ class TestBot:
|
|||
assert bot.answer_inline_query(1234, results=inline_results_callback, current_offset=6)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_get_user_profile_photos(self, bot, chat_id):
|
||||
user_profile_photos = bot.get_user_profile_photos(chat_id)
|
||||
|
||||
assert user_profile_photos.photos[0][0].file_size == 5403
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_get_one_user_profile_photo(self, bot, chat_id):
|
||||
user_profile_photos = bot.get_user_profile_photos(chat_id, offset=0, limit=1)
|
||||
assert user_profile_photos.photos[0][0].file_size == 5403
|
||||
|
@ -973,7 +954,6 @@ class TestBot:
|
|||
)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_edit_message_text(self, bot, message):
|
||||
message = bot.edit_message_text(
|
||||
text='new_text',
|
||||
|
@ -986,7 +966,6 @@ class TestBot:
|
|||
assert message.text == 'new_text'
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_edit_message_text_entities(self, bot, message):
|
||||
test_string = 'Italic Bold Code'
|
||||
entities = [
|
||||
|
@ -1005,7 +984,6 @@ class TestBot:
|
|||
assert message.entities == entities
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize('default_bot', [{'parse_mode': 'Markdown'}], indirect=True)
|
||||
def test_edit_message_text_default_parse_mode(self, default_bot, message):
|
||||
test_string = 'Italic Bold Code'
|
||||
|
@ -1051,7 +1029,6 @@ class TestBot:
|
|||
pass
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_edit_message_caption(self, bot, media_message):
|
||||
message = bot.edit_message_caption(
|
||||
caption='new_caption',
|
||||
|
@ -1062,7 +1039,6 @@ class TestBot:
|
|||
assert message.caption == 'new_caption'
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_edit_message_caption_entities(self, bot, media_message):
|
||||
test_string = 'Italic Bold Code'
|
||||
entities = [
|
||||
|
@ -1083,7 +1059,6 @@ class TestBot:
|
|||
# edit_message_media is tested in test_inputmedia
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize('default_bot', [{'parse_mode': 'Markdown'}], indirect=True)
|
||||
def test_edit_message_caption_default_parse_mode(self, default_bot, media_message):
|
||||
test_string = 'Italic Bold Code'
|
||||
|
@ -1121,7 +1096,6 @@ class TestBot:
|
|||
assert message.caption_markdown == escape_markdown(test_markdown_string)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_edit_message_caption_with_parse_mode(self, bot, media_message):
|
||||
message = bot.edit_message_caption(
|
||||
caption='new *caption*',
|
||||
|
@ -1141,7 +1115,6 @@ class TestBot:
|
|||
pass
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_edit_reply_markup(self, bot, message):
|
||||
new_markup = InlineKeyboardMarkup([[InlineKeyboardButton(text='test', callback_data='1')]])
|
||||
message = bot.edit_message_reply_markup(
|
||||
|
@ -1161,7 +1134,6 @@ class TestBot:
|
|||
|
||||
# TODO: Actually send updates to the test bot so this can be tested properly
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_get_updates(self, bot):
|
||||
bot.delete_webhook() # make sure there is no webhook set if webhook tests failed
|
||||
updates = bot.get_updates(timeout=1)
|
||||
|
@ -1171,7 +1143,6 @@ class TestBot:
|
|||
assert isinstance(updates[0], Update)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(15)
|
||||
@pytest.mark.xfail
|
||||
def test_set_webhook_get_webhook_info_and_delete_webhook(self, bot):
|
||||
url = 'https://python-telegram-bot.org/test/webhook'
|
||||
|
@ -1208,7 +1179,6 @@ class TestBot:
|
|||
assert bot.delete_webhook(drop_pending_updates=drop_pending_updates)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_leave_chat(self, bot):
|
||||
with pytest.raises(BadRequest, match='Chat not found'):
|
||||
bot.leave_chat(-123456)
|
||||
|
@ -1217,7 +1187,6 @@ class TestBot:
|
|||
bot.leave_chat(-123456)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_get_chat(self, bot, super_group_id):
|
||||
chat = bot.get_chat(super_group_id)
|
||||
|
||||
|
@ -1226,7 +1195,6 @@ class TestBot:
|
|||
assert chat.id == int(super_group_id)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_get_chat_administrators(self, bot, channel_id):
|
||||
admins = bot.get_chat_administrators(channel_id)
|
||||
assert isinstance(admins, list)
|
||||
|
@ -1235,14 +1203,12 @@ class TestBot:
|
|||
assert a.status in ('administrator', 'creator')
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_get_chat_members_count(self, bot, channel_id):
|
||||
count = bot.get_chat_members_count(channel_id)
|
||||
assert isinstance(count, int)
|
||||
assert count > 3
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_get_chat_member(self, bot, channel_id, chat_id):
|
||||
chat_member = bot.get_chat_member(channel_id, chat_id)
|
||||
|
||||
|
@ -1259,7 +1225,6 @@ class TestBot:
|
|||
pass
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_game(self, bot, chat_id):
|
||||
game_short_name = 'test_game'
|
||||
message = bot.send_game(chat_id, game_short_name)
|
||||
|
@ -1274,7 +1239,6 @@ class TestBot:
|
|||
assert message.game.photo[0].file_size in [851, 4928]
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize(
|
||||
'default_bot,custom',
|
||||
[
|
||||
|
@ -1310,7 +1274,6 @@ class TestBot:
|
|||
)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_set_game_score_1(self, bot, chat_id):
|
||||
# NOTE: numbering of methods assures proper order between test_set_game_scoreX methods
|
||||
|
||||
|
@ -1333,7 +1296,6 @@ class TestBot:
|
|||
expect_bad_request(func, 'Bot_score_not_modified', 'This test is a diva for some reason.')
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_set_game_score_2(self, bot, chat_id):
|
||||
# NOTE: numbering of methods assures proper order between test_set_game_scoreX methods
|
||||
game_short_name = 'test_game'
|
||||
|
@ -1355,7 +1317,6 @@ class TestBot:
|
|||
assert message.game.text == game.game.text
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_set_game_score_3(self, bot, chat_id):
|
||||
# NOTE: numbering of methods assures proper order between test_set_game_scoreX methods
|
||||
game_short_name = 'test_game'
|
||||
|
@ -1369,7 +1330,6 @@ class TestBot:
|
|||
)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_set_game_score_4(self, bot, chat_id):
|
||||
# NOTE: numbering of methods assures proper order between test_set_game_scoreX methods
|
||||
game_short_name = 'test_game'
|
||||
|
@ -1395,7 +1355,6 @@ class TestBot:
|
|||
assert str(score) in game2.game.text
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_set_game_score_too_low_score(self, bot, chat_id):
|
||||
# We need a game to set the score for
|
||||
game_short_name = 'test_game'
|
||||
|
@ -1407,7 +1366,6 @@ class TestBot:
|
|||
)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_get_game_high_scores(self, bot, chat_id):
|
||||
# We need a game to get the scores for
|
||||
game_short_name = 'test_game'
|
||||
|
@ -1493,7 +1451,6 @@ class TestBot:
|
|||
bot.answer_pre_checkout_query(1, False)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_restrict_chat_member(self, bot, channel_id, chat_permissions):
|
||||
# TODO: Add bot to supergroup so this can be tested properly
|
||||
with pytest.raises(BadRequest, match='Method is available only for supergroups'):
|
||||
|
@ -1521,7 +1478,6 @@ class TestBot:
|
|||
)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_promote_chat_member(self, bot, channel_id, monkeypatch):
|
||||
# TODO: Add bot to supergroup so this can be tested properly / give bot perms
|
||||
with pytest.raises(BadRequest, match='Not enough rights'):
|
||||
|
@ -1578,7 +1534,6 @@ class TestBot:
|
|||
)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_export_chat_invite_link(self, bot, channel_id):
|
||||
# Each link is unique apparently
|
||||
invite_link = bot.export_chat_invite_link(channel_id)
|
||||
|
@ -1586,7 +1541,6 @@ class TestBot:
|
|||
assert invite_link != ''
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize('datetime', argvalues=[True, False], ids=['datetime', 'integer'])
|
||||
def test_advanced_chat_invite_links(self, bot, channel_id, datetime):
|
||||
# we are testing this all in one function in order to save api calls
|
||||
|
@ -1621,7 +1575,6 @@ class TestBot:
|
|||
assert revoked_invite_link.is_revoked is True
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_advanced_chat_invite_links_default_tzinfo(self, tz_bot, channel_id):
|
||||
# we are testing this all in one function in order to save api calls
|
||||
add_seconds = dtm.timedelta(0, 70)
|
||||
|
@ -1652,7 +1605,6 @@ class TestBot:
|
|||
assert revoked_invite_link.is_revoked is True
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_set_chat_photo(self, bot, channel_id):
|
||||
def func():
|
||||
assert bot.set_chat_photo(channel_id, f)
|
||||
|
@ -1675,7 +1627,6 @@ class TestBot:
|
|||
assert test_flag
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_delete_chat_photo(self, bot, channel_id):
|
||||
def func():
|
||||
assert bot.delete_chat_photo(channel_id)
|
||||
|
@ -1683,18 +1634,15 @@ class TestBot:
|
|||
expect_bad_request(func, 'Chat_not_modified', 'Chat photo was not set.')
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_set_chat_title(self, bot, channel_id):
|
||||
assert bot.set_chat_title(channel_id, '>>> telegram.Bot() - Tests')
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_set_chat_description(self, bot, channel_id):
|
||||
assert bot.set_chat_description(channel_id, 'Time: ' + str(time.time()))
|
||||
|
||||
# TODO: Add bot to group to test there too
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(20)
|
||||
def test_pin_and_unpin_message(self, bot, super_group_id):
|
||||
message1 = bot.send_message(super_group_id, text="test_pin_message_1")
|
||||
message2 = bot.send_message(super_group_id, text="test_pin_message_2")
|
||||
|
@ -1773,7 +1721,6 @@ class TestBot:
|
|||
bot.send_photo(chat_id, open('tests/data/telegram.jpg', 'rb'))
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_message_entities(self, bot, chat_id):
|
||||
test_string = 'Italic Bold Code'
|
||||
entities = [
|
||||
|
@ -1786,7 +1733,6 @@ class TestBot:
|
|||
assert message.entities == entities
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize('default_bot', [{'parse_mode': 'Markdown'}], indirect=True)
|
||||
def test_send_message_default_parse_mode(self, default_bot, chat_id):
|
||||
test_string = 'Italic Bold Code'
|
||||
|
@ -1805,7 +1751,6 @@ class TestBot:
|
|||
assert message.text_markdown == escape_markdown(test_markdown_string)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize(
|
||||
'default_bot,custom',
|
||||
[
|
||||
|
@ -1838,7 +1783,6 @@ class TestBot:
|
|||
)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_set_and_get_my_commands(self, bot):
|
||||
commands = [
|
||||
BotCommand('cmd1', 'descr1'),
|
||||
|
@ -1857,7 +1801,6 @@ class TestBot:
|
|||
assert bc[1].description == 'descr2'
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_set_and_get_my_commands_strings(self, bot):
|
||||
commands = [
|
||||
['cmd1', 'descr1'],
|
||||
|
@ -1894,7 +1837,6 @@ class TestBot:
|
|||
assert bot.close()
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize('json_keyboard', [True, False])
|
||||
def test_copy_message(self, monkeypatch, bot, chat_id, media_message, json_keyboard):
|
||||
keyboard = InlineKeyboardMarkup(
|
||||
|
@ -1927,7 +1869,6 @@ class TestBot:
|
|||
)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_copy_message_without_reply(self, bot, chat_id, media_message):
|
||||
keyboard = InlineKeyboardMarkup(
|
||||
[[InlineKeyboardButton(text="test", callback_data="test2")]]
|
||||
|
@ -1952,7 +1893,6 @@ class TestBot:
|
|||
assert message.reply_markup == keyboard
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize(
|
||||
'default_bot',
|
||||
[
|
||||
|
|
|
@ -53,7 +53,6 @@ class TestChatPhoto:
|
|||
chatphoto_file_url = 'https://python-telegram-bot.org/static/testfiles/telegram.jpg'
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_all_args(self, bot, super_group_id, chatphoto_file, chat_photo, thumb_file):
|
||||
def func():
|
||||
assert bot.set_chat_photo(super_group_id, chatphoto_file)
|
||||
|
@ -61,7 +60,6 @@ class TestChatPhoto:
|
|||
expect_bad_request(func, 'Type of file mismatch', 'Telegram did not accept the file.')
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_get_and_download(self, bot, chat_photo):
|
||||
new_file = bot.get_file(chat_photo.small_file_id)
|
||||
|
||||
|
@ -112,7 +110,6 @@ class TestChatPhoto:
|
|||
assert chat_photo_dict['big_file_unique_id'] == chat_photo.big_file_unique_id
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_error_send_empty_file(self, bot, super_group_id):
|
||||
chatphoto_file = open(os.devnull, 'rb')
|
||||
|
||||
|
@ -120,7 +117,6 @@ class TestChatPhoto:
|
|||
bot.set_chat_photo(chat_id=super_group_id, photo=chatphoto_file)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_error_send_empty_file_id(self, bot, super_group_id):
|
||||
with pytest.raises(TelegramError):
|
||||
bot.set_chat_photo(chat_id=super_group_id, photo='')
|
||||
|
|
|
@ -25,7 +25,6 @@ from telegram.error import BadRequest
|
|||
|
||||
class TestConstants:
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_max_message_length(self, bot, chat_id):
|
||||
bot.send_message(chat_id=chat_id, text='a' * constants.MAX_MESSAGE_LENGTH)
|
||||
|
||||
|
@ -36,7 +35,6 @@ class TestConstants:
|
|||
bot.send_message(chat_id=chat_id, text='a' * (constants.MAX_MESSAGE_LENGTH + 1))
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_max_caption_length(self, bot, chat_id):
|
||||
good_caption = 'a' * constants.MAX_CAPTION_LENGTH
|
||||
with open('tests/data/telegram.png', 'rb') as f:
|
||||
|
|
|
@ -73,7 +73,6 @@ class TestContact:
|
|||
assert message
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize(
|
||||
'default_bot,custom',
|
||||
[
|
||||
|
|
|
@ -20,6 +20,7 @@ import logging
|
|||
from time import sleep
|
||||
|
||||
import pytest
|
||||
from flaky import flaky
|
||||
|
||||
from telegram import (
|
||||
CallbackQuery,
|
||||
|
@ -1064,6 +1065,7 @@ class TestConversationHandler:
|
|||
assert handler.conversations.get((self.group.id, user1.id)) is None
|
||||
assert self.is_timeout
|
||||
|
||||
@flaky(3, 1)
|
||||
def test_conversation_timeout_keeps_extending(self, dp, bot, user1):
|
||||
handler = ConversationHandler(
|
||||
entry_points=self.entry_points,
|
||||
|
|
|
@ -69,7 +69,6 @@ class TestDocument:
|
|||
assert document.thumb.height == self.thumb_height
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_all_args(self, bot, chat_id, document_file, document, thumb_file):
|
||||
message = bot.send_document(
|
||||
chat_id,
|
||||
|
@ -95,7 +94,6 @@ class TestDocument:
|
|||
assert message.document.thumb.height == self.thumb_height
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_get_and_download(self, bot, document):
|
||||
new_file = bot.get_file(document.file_id)
|
||||
|
||||
|
@ -109,7 +107,6 @@ class TestDocument:
|
|||
assert os.path.isfile('telegram.png')
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_url_gif_file(self, bot, chat_id):
|
||||
message = bot.send_document(chat_id, self.document_file_url)
|
||||
|
||||
|
@ -126,7 +123,6 @@ class TestDocument:
|
|||
assert document.file_size == 3878
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_resend(self, bot, chat_id, document):
|
||||
message = bot.send_document(chat_id=chat_id, document=document.file_id)
|
||||
|
||||
|
@ -153,7 +149,6 @@ class TestDocument:
|
|||
assert message
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_document_caption_entities(self, bot, chat_id, document):
|
||||
test_string = 'Italic Bold Code'
|
||||
entities = [
|
||||
|
@ -169,7 +164,6 @@ class TestDocument:
|
|||
assert message.caption_entities == entities
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize('default_bot', [{'parse_mode': 'Markdown'}], indirect=True)
|
||||
def test_send_document_default_parse_mode_1(self, default_bot, chat_id, document):
|
||||
test_string = 'Italic Bold Code'
|
||||
|
@ -180,7 +174,6 @@ class TestDocument:
|
|||
assert message.caption == test_string
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize('default_bot', [{'parse_mode': 'Markdown'}], indirect=True)
|
||||
def test_send_document_default_parse_mode_2(self, default_bot, chat_id, document):
|
||||
test_markdown_string = '_Italic_ *Bold* `Code`'
|
||||
|
@ -192,7 +185,6 @@ class TestDocument:
|
|||
assert message.caption_markdown == escape_markdown(test_markdown_string)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize('default_bot', [{'parse_mode': 'Markdown'}], indirect=True)
|
||||
def test_send_document_default_parse_mode_3(self, default_bot, chat_id, document):
|
||||
test_markdown_string = '_Italic_ *Bold* `Code`'
|
||||
|
@ -204,7 +196,6 @@ class TestDocument:
|
|||
assert message.caption_markdown == escape_markdown(test_markdown_string)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize(
|
||||
'default_bot,custom',
|
||||
[
|
||||
|
@ -281,14 +272,12 @@ class TestDocument:
|
|||
assert document_dict['file_size'] == document.file_size
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_error_send_empty_file(self, bot, chat_id):
|
||||
with open(os.devnull, 'rb') as f:
|
||||
with pytest.raises(TelegramError):
|
||||
bot.send_document(chat_id=chat_id, document=f)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_error_send_empty_file_id(self, bot, chat_id):
|
||||
with pytest.raises(TelegramError):
|
||||
bot.send_document(chat_id=chat_id, document='')
|
||||
|
|
|
@ -81,7 +81,6 @@ class TestFile:
|
|||
assert file_dict['file_size'] == file.file_size
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_error_get_empty_file_id(self, bot):
|
||||
with pytest.raises(TelegramError):
|
||||
bot.get_file(file_id='')
|
||||
|
|
|
@ -33,7 +33,6 @@ class TestForceReply:
|
|||
selective = True
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_message_with_force_reply(self, bot, chat_id, force_reply):
|
||||
message = bot.send_message(chat_id, 'text', reply_markup=force_reply)
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@ class TestInlineKeyboardMarkup:
|
|||
]
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_message_with_inline_keyboard_markup(self, bot, chat_id, inline_keyboard_markup):
|
||||
message = bot.send_message(
|
||||
chat_id, 'Testing InlineKeyboardMarkup', reply_markup=inline_keyboard_markup
|
||||
|
@ -88,12 +87,12 @@ class TestInlineKeyboardMarkup:
|
|||
):
|
||||
if reply_markup is not None:
|
||||
if isinstance(reply_markup, ReplyMarkup):
|
||||
data['reply_markup'] = reply_markup.to_json()
|
||||
data['reply_markup'] = reply_markup.to_dict()
|
||||
else:
|
||||
data['reply_markup'] = reply_markup
|
||||
|
||||
assert bool('"switch_inline_query": ""' in data['reply_markup'])
|
||||
assert bool('"switch_inline_query_current_chat": ""' in data['reply_markup'])
|
||||
assert bool("'switch_inline_query': ''" in str(data['reply_markup']))
|
||||
assert bool("'switch_inline_query_current_chat': ''" in str(data['reply_markup']))
|
||||
|
||||
inline_keyboard_markup.inline_keyboard[0][0].callback_data = None
|
||||
inline_keyboard_markup.inline_keyboard[0][0].switch_inline_query = ''
|
||||
|
|
|
@ -402,7 +402,6 @@ def media_group(photo, thumb): # noqa: F811
|
|||
|
||||
class TestSendMediaGroup:
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_media_group_photo(self, bot, chat_id, media_group):
|
||||
messages = bot.send_media_group(chat_id, media_group)
|
||||
assert isinstance(messages, list)
|
||||
|
@ -415,7 +414,6 @@ class TestSendMediaGroup:
|
|||
)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_media_group_all_args(self, bot, chat_id, media_group):
|
||||
m1 = bot.send_message(chat_id, text="test")
|
||||
messages = bot.send_media_group(
|
||||
|
@ -431,7 +429,6 @@ class TestSendMediaGroup:
|
|||
)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_media_group_custom_filename(
|
||||
self,
|
||||
bot,
|
||||
|
@ -474,7 +471,6 @@ class TestSendMediaGroup:
|
|||
bot.send_media_group(chat_id, [input_video, input_video])
|
||||
|
||||
@flaky(3, 1) # noqa: F811
|
||||
@pytest.mark.timeout(10) # noqa: F811
|
||||
def test_send_media_group_new_files(
|
||||
self, bot, chat_id, video_file, photo_file, animation_file # noqa: F811
|
||||
): # noqa: F811
|
||||
|
@ -499,7 +495,6 @@ class TestSendMediaGroup:
|
|||
assert all([mes.media_group_id == messages[0].media_group_id for mes in messages])
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize(
|
||||
'default_bot,custom',
|
||||
[
|
||||
|
@ -534,7 +529,6 @@ class TestSendMediaGroup:
|
|||
)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_edit_message_media(self, bot, chat_id, media_group):
|
||||
messages = bot.send_media_group(chat_id, media_group)
|
||||
cid = messages[-1].chat.id
|
||||
|
@ -543,7 +537,6 @@ class TestSendMediaGroup:
|
|||
assert isinstance(new_message, Message)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_edit_message_media_new_file(self, bot, chat_id, media_group, thumb_file):
|
||||
messages = bot.send_media_group(chat_id, media_group)
|
||||
cid = messages[-1].chat.id
|
||||
|
@ -554,7 +547,6 @@ class TestSendMediaGroup:
|
|||
assert isinstance(new_message, Message)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize(
|
||||
'default_bot', [{'parse_mode': ParseMode.HTML}], indirect=True, ids=['HTML-Bot']
|
||||
)
|
||||
|
|
|
@ -76,7 +76,6 @@ class TestInvoice:
|
|||
assert invoice_dict['total_amount'] == invoice.total_amount
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_required_args_only(self, bot, chat_id, provider_token):
|
||||
message = bot.send_invoice(
|
||||
chat_id=chat_id,
|
||||
|
@ -95,7 +94,6 @@ class TestInvoice:
|
|||
assert message.invoice.total_amount == self.total_amount
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_all_args(self, bot, chat_id, provider_token):
|
||||
message = bot.send_invoice(
|
||||
chat_id,
|
||||
|
@ -152,7 +150,6 @@ class TestInvoice:
|
|||
)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize(
|
||||
'default_bot,custom',
|
||||
[
|
||||
|
|
|
@ -64,7 +64,6 @@ class TestLocation:
|
|||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.xfail
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_live_location(self, bot, chat_id):
|
||||
message = bot.send_location(
|
||||
chat_id=chat_id,
|
||||
|
@ -144,7 +143,6 @@ class TestLocation:
|
|||
assert bot.send_location(location=location, chat_id=chat_id)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize(
|
||||
'default_bot,custom',
|
||||
[
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU Lesser Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
import pytest
|
||||
from flaky import flaky
|
||||
|
||||
from telegram import ParseMode
|
||||
|
@ -31,7 +30,6 @@ class TestParseMode:
|
|||
formatted_text_formatted = 'bold italic link name.'
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_message_with_parse_mode_markdown(self, bot, chat_id):
|
||||
message = bot.send_message(
|
||||
chat_id=chat_id, text=self.markdown_text, parse_mode=ParseMode.MARKDOWN
|
||||
|
@ -40,7 +38,6 @@ class TestParseMode:
|
|||
assert message.text == self.formatted_text_formatted
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_message_with_parse_mode_html(self, bot, chat_id):
|
||||
message = bot.send_message(chat_id=chat_id, text=self.html_text, parse_mode=ParseMode.HTML)
|
||||
|
||||
|
|
|
@ -89,7 +89,6 @@ class TestPhoto:
|
|||
assert thumb.height == 320
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_photo_all_args(self, bot, chat_id, photo_file, thumb, photo):
|
||||
message = bot.send_photo(
|
||||
chat_id,
|
||||
|
@ -120,7 +119,6 @@ class TestPhoto:
|
|||
assert message.caption == TestPhoto.caption.replace('*', '')
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_photo_custom_filename(self, bot, chat_id, photo_file, monkeypatch):
|
||||
def make_assertion(url, data, **kwargs):
|
||||
return data['photo'].filename == 'custom_filename'
|
||||
|
@ -130,7 +128,6 @@ class TestPhoto:
|
|||
assert bot.send_photo(chat_id, photo_file, filename='custom_filename')
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_photo_parse_mode_markdown(self, bot, chat_id, photo_file, thumb, photo):
|
||||
message = bot.send_photo(chat_id, photo_file, caption=self.caption, parse_mode='Markdown')
|
||||
assert isinstance(message.photo[0], PhotoSize)
|
||||
|
@ -155,7 +152,6 @@ class TestPhoto:
|
|||
assert len(message.caption_entities) == 1
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_photo_parse_mode_html(self, bot, chat_id, photo_file, thumb, photo):
|
||||
message = bot.send_photo(chat_id, photo_file, caption=self.caption, parse_mode='HTML')
|
||||
assert isinstance(message.photo[0], PhotoSize)
|
||||
|
@ -180,7 +176,6 @@ class TestPhoto:
|
|||
assert len(message.caption_entities) == 1
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_photo_caption_entities(self, bot, chat_id, photo_file, thumb, photo):
|
||||
test_string = 'Italic Bold Code'
|
||||
entities = [
|
||||
|
@ -196,7 +191,6 @@ class TestPhoto:
|
|||
assert message.caption_entities == entities
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize('default_bot', [{'parse_mode': 'Markdown'}], indirect=True)
|
||||
def test_send_photo_default_parse_mode_1(self, default_bot, chat_id, photo_file, thumb, photo):
|
||||
test_string = 'Italic Bold Code'
|
||||
|
@ -207,7 +201,6 @@ class TestPhoto:
|
|||
assert message.caption == test_string
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize('default_bot', [{'parse_mode': 'Markdown'}], indirect=True)
|
||||
def test_send_photo_default_parse_mode_2(self, default_bot, chat_id, photo_file, thumb, photo):
|
||||
test_markdown_string = '_Italic_ *Bold* `Code`'
|
||||
|
@ -219,7 +212,6 @@ class TestPhoto:
|
|||
assert message.caption_markdown == escape_markdown(test_markdown_string)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize('default_bot', [{'parse_mode': 'Markdown'}], indirect=True)
|
||||
def test_send_photo_default_parse_mode_3(self, default_bot, chat_id, photo_file, thumb, photo):
|
||||
test_markdown_string = '_Italic_ *Bold* `Code`'
|
||||
|
@ -245,7 +237,6 @@ class TestPhoto:
|
|||
assert test_flag
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize(
|
||||
'default_bot,custom',
|
||||
[
|
||||
|
@ -280,7 +271,6 @@ class TestPhoto:
|
|||
)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_get_and_download(self, bot, photo):
|
||||
new_file = bot.getFile(photo.file_id)
|
||||
|
||||
|
@ -293,7 +283,6 @@ class TestPhoto:
|
|||
assert os.path.isfile('telegram.jpg') is True
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_url_jpg_file(self, bot, chat_id, thumb, photo):
|
||||
message = bot.send_photo(chat_id, photo=self.photo_file_url)
|
||||
|
||||
|
@ -314,7 +303,6 @@ class TestPhoto:
|
|||
# sending by URL and sending by upload differently and it's not really our job anyway ...
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_url_png_file(self, bot, chat_id):
|
||||
message = bot.send_photo(
|
||||
photo='http://dummyimage.com/600x400/000/fff.png&text=telegram', chat_id=chat_id
|
||||
|
@ -329,7 +317,6 @@ class TestPhoto:
|
|||
assert photo.file_unique_id != ''
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_url_gif_file(self, bot, chat_id):
|
||||
message = bot.send_photo(
|
||||
photo='http://dummyimage.com/600x400/000/fff.png&text=telegram', chat_id=chat_id
|
||||
|
@ -344,7 +331,6 @@ class TestPhoto:
|
|||
assert photo.file_unique_id != ''
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_file_unicode_filename(self, bot, chat_id):
|
||||
"""
|
||||
Regression test for https://github.com/python-telegram-bot/python-telegram-bot/issues/1202
|
||||
|
@ -361,7 +347,6 @@ class TestPhoto:
|
|||
assert photo.file_unique_id != ''
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_bytesio_jpg_file(self, bot, chat_id):
|
||||
file_name = 'tests/data/telegram_no_standard_header.jpg'
|
||||
|
||||
|
@ -398,7 +383,6 @@ class TestPhoto:
|
|||
assert message
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_resend(self, bot, chat_id, photo):
|
||||
message = bot.send_photo(chat_id=chat_id, photo=photo.file_id)
|
||||
|
||||
|
@ -449,13 +433,11 @@ class TestPhoto:
|
|||
assert photo_dict['file_size'] == photo.file_size
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_error_send_empty_file(self, bot, chat_id):
|
||||
with pytest.raises(TelegramError):
|
||||
bot.send_photo(chat_id=chat_id, photo=open(os.devnull, 'rb'))
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_error_send_empty_file_id(self, bot, chat_id):
|
||||
with pytest.raises(TelegramError):
|
||||
bot.send_photo(chat_id=chat_id, photo='')
|
||||
|
|
|
@ -40,14 +40,12 @@ class TestReplyKeyboardMarkup:
|
|||
selective = True
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_message_with_reply_keyboard_markup(self, bot, chat_id, reply_keyboard_markup):
|
||||
message = bot.send_message(chat_id, 'Text', reply_markup=reply_keyboard_markup)
|
||||
|
||||
assert message.text == 'Text'
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_message_with_data_markup(self, bot, chat_id):
|
||||
message = bot.send_message(chat_id, 'text 2', reply_markup={'keyboard': [['1', '2']]})
|
||||
|
||||
|
|
|
@ -33,7 +33,6 @@ class TestReplyKeyboardRemove:
|
|||
selective = True
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_message_with_reply_keyboard_remove(self, bot, chat_id, reply_keyboard_remove):
|
||||
message = bot.send_message(chat_id, 'Text', reply_markup=reply_keyboard_remove)
|
||||
|
||||
|
|
|
@ -97,7 +97,6 @@ class TestSticker:
|
|||
assert sticker.thumb.file_size == self.thumb_file_size
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_all_args(self, bot, chat_id, sticker_file, sticker):
|
||||
message = bot.send_sticker(chat_id, sticker=sticker_file, disable_notification=False)
|
||||
|
||||
|
@ -121,7 +120,6 @@ class TestSticker:
|
|||
assert message.sticker.thumb.file_size == sticker.thumb.file_size
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_get_and_download(self, bot, sticker):
|
||||
new_file = bot.get_file(sticker.file_id)
|
||||
|
||||
|
@ -135,14 +133,12 @@ class TestSticker:
|
|||
assert os.path.isfile('telegram.webp')
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_resend(self, bot, chat_id, sticker):
|
||||
message = bot.send_sticker(chat_id=chat_id, sticker=sticker.file_id)
|
||||
|
||||
assert message.sticker == sticker
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_on_server_emoji(self, bot, chat_id):
|
||||
server_file_id = 'CAADAQADHAADyIsGAAFZfq1bphjqlgI'
|
||||
message = bot.send_sticker(chat_id=chat_id, sticker=server_file_id)
|
||||
|
@ -150,7 +146,6 @@ class TestSticker:
|
|||
assert sticker.emoji == self.emoji
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_from_url(self, bot, chat_id):
|
||||
message = bot.send_sticker(chat_id=chat_id, sticker=self.sticker_file_url)
|
||||
sticker = message.sticker
|
||||
|
@ -219,7 +214,6 @@ class TestSticker:
|
|||
assert test_flag
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize(
|
||||
'default_bot,custom',
|
||||
[
|
||||
|
@ -266,13 +260,11 @@ class TestSticker:
|
|||
assert sticker_dict['thumb'] == sticker.thumb.to_dict()
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_error_send_empty_file(self, bot, chat_id):
|
||||
with pytest.raises(TelegramError):
|
||||
bot.send_sticker(chat_id, open(os.devnull, 'rb'))
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_error_send_empty_file_id(self, bot, chat_id):
|
||||
with pytest.raises(TelegramError):
|
||||
bot.send_sticker(chat_id, '')
|
||||
|
@ -364,7 +356,6 @@ class TestStickerSet:
|
|||
assert sticker_set.thumb == sticker.thumb
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_bot_methods_1_png(self, bot, chat_id, sticker_file):
|
||||
with open('tests/data/telegram_sticker.png', 'rb') as f:
|
||||
file = bot.upload_sticker_file(95205500, f)
|
||||
|
@ -382,7 +373,6 @@ class TestStickerSet:
|
|||
)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_bot_methods_1_tgs(self, bot, chat_id):
|
||||
assert bot.add_sticker_to_set(
|
||||
chat_id,
|
||||
|
@ -402,19 +392,16 @@ class TestStickerSet:
|
|||
assert sticker_set_dict['stickers'][0] == sticker_set.stickers[0].to_dict()
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_bot_methods_2_png(self, bot, sticker_set):
|
||||
file_id = sticker_set.stickers[0].file_id
|
||||
assert bot.set_sticker_position_in_set(file_id, 1)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_bot_methods_2_tgs(self, bot, animated_sticker_set):
|
||||
file_id = animated_sticker_set.stickers[0].file_id
|
||||
assert bot.set_sticker_position_in_set(file_id, 1)
|
||||
|
||||
@flaky(10, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_bot_methods_3_png(self, bot, chat_id, sticker_set_thumb_file):
|
||||
sleep(1)
|
||||
assert bot.set_sticker_set_thumb(
|
||||
|
@ -422,7 +409,6 @@ class TestStickerSet:
|
|||
)
|
||||
|
||||
@flaky(10, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_bot_methods_3_tgs(self, bot, chat_id, animated_sticker_file, animated_sticker_set):
|
||||
sleep(1)
|
||||
assert bot.set_sticker_set_thumb(
|
||||
|
@ -433,14 +419,12 @@ class TestStickerSet:
|
|||
assert bot.set_sticker_set_thumb(f'animated_test_by_{bot.username}', chat_id, file_id)
|
||||
|
||||
@flaky(10, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_bot_methods_4_png(self, bot, sticker_set):
|
||||
sleep(1)
|
||||
file_id = sticker_set.stickers[-1].file_id
|
||||
assert bot.delete_sticker_from_set(file_id)
|
||||
|
||||
@flaky(10, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_bot_methods_4_tgs(self, bot, animated_sticker_set):
|
||||
sleep(1)
|
||||
file_id = animated_sticker_set.stickers[-1].file_id
|
||||
|
|
|
@ -84,7 +84,6 @@ class TestVenue:
|
|||
assert message
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize(
|
||||
'default_bot,custom',
|
||||
[
|
||||
|
|
|
@ -82,7 +82,6 @@ class TestVideo:
|
|||
assert video.mime_type == self.mime_type
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_all_args(self, bot, chat_id, video_file, video, thumb_file):
|
||||
message = bot.send_video(
|
||||
chat_id,
|
||||
|
@ -116,7 +115,6 @@ class TestVideo:
|
|||
assert message.video.file_name == self.file_name
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_video_custom_filename(self, bot, chat_id, video_file, monkeypatch):
|
||||
def make_assertion(url, data, **kwargs):
|
||||
return data['video'].filename == 'custom_filename'
|
||||
|
@ -126,7 +124,6 @@ class TestVideo:
|
|||
assert bot.send_video(chat_id, video_file, filename='custom_filename')
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_get_and_download(self, bot, video):
|
||||
new_file = bot.get_file(video.file_id)
|
||||
|
||||
|
@ -140,7 +137,6 @@ class TestVideo:
|
|||
assert os.path.isfile('telegram.mp4')
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_mp4_file_url(self, bot, chat_id, video):
|
||||
message = bot.send_video(chat_id, self.video_file_url, caption=self.caption)
|
||||
|
||||
|
@ -166,7 +162,6 @@ class TestVideo:
|
|||
assert message.caption == self.caption
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_video_caption_entities(self, bot, chat_id, video):
|
||||
test_string = 'Italic Bold Code'
|
||||
entities = [
|
||||
|
@ -180,7 +175,6 @@ class TestVideo:
|
|||
assert message.caption_entities == entities
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_resend(self, bot, chat_id, video):
|
||||
message = bot.send_video(chat_id, video.file_id)
|
||||
|
||||
|
@ -195,7 +189,6 @@ class TestVideo:
|
|||
assert message
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize('default_bot', [{'parse_mode': 'Markdown'}], indirect=True)
|
||||
def test_send_video_default_parse_mode_1(self, default_bot, chat_id, video):
|
||||
test_string = 'Italic Bold Code'
|
||||
|
@ -206,7 +199,6 @@ class TestVideo:
|
|||
assert message.caption == test_string
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize('default_bot', [{'parse_mode': 'Markdown'}], indirect=True)
|
||||
def test_send_video_default_parse_mode_2(self, default_bot, chat_id, video):
|
||||
test_markdown_string = '_Italic_ *Bold* `Code`'
|
||||
|
@ -218,7 +210,6 @@ class TestVideo:
|
|||
assert message.caption_markdown == escape_markdown(test_markdown_string)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize('default_bot', [{'parse_mode': 'Markdown'}], indirect=True)
|
||||
def test_send_video_default_parse_mode_3(self, default_bot, chat_id, video):
|
||||
test_markdown_string = '_Italic_ *Bold* `Code`'
|
||||
|
@ -244,7 +235,6 @@ class TestVideo:
|
|||
assert test_flag
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize(
|
||||
'default_bot,custom',
|
||||
[
|
||||
|
@ -314,13 +304,11 @@ class TestVideo:
|
|||
assert video_dict['file_name'] == video.file_name
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_error_send_empty_file(self, bot, chat_id):
|
||||
with pytest.raises(TelegramError):
|
||||
bot.send_video(chat_id, open(os.devnull, 'rb'))
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_error_send_empty_file_id(self, bot, chat_id):
|
||||
with pytest.raises(TelegramError):
|
||||
bot.send_video(chat_id, '')
|
||||
|
|
|
@ -73,7 +73,6 @@ class TestVideoNote:
|
|||
assert video_note.file_size == self.file_size
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_all_args(self, bot, chat_id, video_note_file, video_note, thumb_file):
|
||||
message = bot.send_video_note(
|
||||
chat_id,
|
||||
|
@ -98,7 +97,6 @@ class TestVideoNote:
|
|||
assert message.video_note.thumb.height == self.thumb_height
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_video_note_custom_filename(self, bot, chat_id, video_note_file, monkeypatch):
|
||||
def make_assertion(url, data, **kwargs):
|
||||
return data['video_note'].filename == 'custom_filename'
|
||||
|
@ -108,7 +106,6 @@ class TestVideoNote:
|
|||
assert bot.send_video_note(chat_id, video_note_file, filename='custom_filename')
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_get_and_download(self, bot, video_note):
|
||||
new_file = bot.get_file(video_note.file_id)
|
||||
|
||||
|
@ -122,7 +119,6 @@ class TestVideoNote:
|
|||
assert os.path.isfile('telegram2.mp4')
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_resend(self, bot, chat_id, video_note):
|
||||
message = bot.send_video_note(chat_id, video_note.file_id)
|
||||
|
||||
|
@ -177,7 +173,6 @@ class TestVideoNote:
|
|||
assert test_flag
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize(
|
||||
'default_bot,custom',
|
||||
[
|
||||
|
@ -212,13 +207,11 @@ class TestVideoNote:
|
|||
)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_error_send_empty_file(self, bot, chat_id):
|
||||
with pytest.raises(TelegramError):
|
||||
bot.send_video_note(chat_id, open(os.devnull, 'rb'))
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_error_send_empty_file_id(self, bot, chat_id):
|
||||
with pytest.raises(TelegramError):
|
||||
bot.send_video_note(chat_id, '')
|
||||
|
|
|
@ -66,7 +66,6 @@ class TestVoice:
|
|||
assert voice.file_size == self.file_size
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_all_args(self, bot, chat_id, voice_file, voice):
|
||||
message = bot.send_voice(
|
||||
chat_id,
|
||||
|
@ -88,7 +87,6 @@ class TestVoice:
|
|||
assert message.caption == self.caption.replace('*', '')
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_voice_custom_filename(self, bot, chat_id, voice_file, monkeypatch):
|
||||
def make_assertion(url, data, **kwargs):
|
||||
return data['voice'].filename == 'custom_filename'
|
||||
|
@ -98,7 +96,6 @@ class TestVoice:
|
|||
assert bot.send_voice(chat_id, voice_file, filename='custom_filename')
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_get_and_download(self, bot, voice):
|
||||
new_file = bot.get_file(voice.file_id)
|
||||
|
||||
|
@ -112,7 +109,6 @@ class TestVoice:
|
|||
assert os.path.isfile('telegram.ogg')
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_ogg_url_file(self, bot, chat_id, voice):
|
||||
message = bot.sendVoice(chat_id, self.voice_file_url, duration=self.duration)
|
||||
|
||||
|
@ -126,7 +122,6 @@ class TestVoice:
|
|||
assert message.voice.file_size == voice.file_size
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_resend(self, bot, chat_id, voice):
|
||||
message = bot.sendVoice(chat_id, voice.file_id)
|
||||
|
||||
|
@ -141,7 +136,6 @@ class TestVoice:
|
|||
assert message
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_send_voice_caption_entities(self, bot, chat_id, voice_file):
|
||||
test_string = 'Italic Bold Code'
|
||||
entities = [
|
||||
|
@ -157,7 +151,6 @@ class TestVoice:
|
|||
assert message.caption_entities == entities
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize('default_bot', [{'parse_mode': 'Markdown'}], indirect=True)
|
||||
def test_send_voice_default_parse_mode_1(self, default_bot, chat_id, voice):
|
||||
test_string = 'Italic Bold Code'
|
||||
|
@ -168,7 +161,6 @@ class TestVoice:
|
|||
assert message.caption == test_string
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize('default_bot', [{'parse_mode': 'Markdown'}], indirect=True)
|
||||
def test_send_voice_default_parse_mode_2(self, default_bot, chat_id, voice):
|
||||
test_markdown_string = '_Italic_ *Bold* `Code`'
|
||||
|
@ -180,7 +172,6 @@ class TestVoice:
|
|||
assert message.caption_markdown == escape_markdown(test_markdown_string)
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize('default_bot', [{'parse_mode': 'Markdown'}], indirect=True)
|
||||
def test_send_voice_default_parse_mode_3(self, default_bot, chat_id, voice):
|
||||
test_markdown_string = '_Italic_ *Bold* `Code`'
|
||||
|
@ -206,7 +197,6 @@ class TestVoice:
|
|||
assert test_flag
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.parametrize(
|
||||
'default_bot,custom',
|
||||
[
|
||||
|
@ -268,13 +258,11 @@ class TestVoice:
|
|||
assert voice_dict['file_size'] == voice.file_size
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_error_send_empty_file(self, bot, chat_id):
|
||||
with pytest.raises(TelegramError):
|
||||
bot.sendVoice(chat_id, open(os.devnull, 'rb'))
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_error_send_empty_file_id(self, bot, chat_id):
|
||||
with pytest.raises(TelegramError):
|
||||
bot.sendVoice(chat_id, '')
|
||||
|
|
Loading…
Reference in a new issue