Skip to content

Commit b2fb426

Browse files
committed
Small test fixes to make them more stable on travis CI
1 parent 19591c9 commit b2fb426

6 files changed

Lines changed: 18 additions & 1 deletion

File tree

tests/test_forcereply.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
# along with this program. If not, see [http://www.gnu.org/licenses/].
1919

2020
import pytest
21+
from flaky import flaky
2122

2223
from telegram import ForceReply
2324

@@ -31,6 +32,8 @@ class TestForceReply(object):
3132
force_reply = True
3233
selective = True
3334

35+
@flaky(3, 1)
36+
@pytest.mark.timeout(10)
3437
def test_send_message_with_force_reply(self, bot, chat_id, force_reply):
3538
message = bot.send_message(chat_id, 'text', reply_markup=force_reply)
3639

tests/test_inlinekeyboardmarkup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
# along with this program. If not, see [http://www.gnu.org/licenses/].
1919

2020
import pytest
21+
from flaky import flaky
2122

2223
from telegram import InlineKeyboardButton, InlineKeyboardMarkup
2324

@@ -33,6 +34,8 @@ class TestInlineKeyboardMarkup(object):
3334
InlineKeyboardButton(text='button2', callback_data='data2')
3435
]]
3536

37+
@flaky(3, 1)
38+
@pytest.mark.timeout(10)
3639
def test_send_message_with_inline_keyboard_markup(self, bot, chat_id, inline_keyboard_markup):
3740
message = bot.send_message(
3841
chat_id,

tests/test_inputmedia.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,8 @@ def test_send_media_group_all_args(self, bot, chat_id, media_group):
316316
assert all([isinstance(mes, Message) for mes in messages])
317317
assert all([mes.media_group_id == messages[0].media_group_id for mes in messages])
318318

319+
@flaky(3, 1) # noqa: F811
320+
@pytest.mark.timeout(10) # noqa: F811
319321
def test_send_media_group_new_files(self, bot, chat_id, video_file, photo_file, # noqa: F811
320322
animation_file): # noqa: F811
321323
messages = bot.send_media_group(chat_id, [

tests/test_parsemode.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#
1717
# You should have received a copy of the GNU Lesser Public License
1818
# along with this program. If not, see [http://www.gnu.org/licenses/].
19+
import pytest
20+
from flaky import flaky
1921

2022
from telegram import ParseMode
2123

@@ -25,12 +27,16 @@ class TestParseMode(object):
2527
html_text = '<b>bold</b> <i>italic</i> <a href="http://google.com">link</a>.'
2628
formatted_text_formatted = u'bold italic link.'
2729

30+
@flaky(3, 1)
31+
@pytest.mark.timeout(10)
2832
def test_send_message_with_parse_mode_markdown(self, bot, chat_id):
2933
message = bot.send_message(chat_id=chat_id, text=self.markdown_text,
3034
parse_mode=ParseMode.MARKDOWN)
3135

3236
assert message.text == self.formatted_text_formatted
3337

38+
@flaky(3, 1)
39+
@pytest.mark.timeout(10)
3440
def test_send_message_with_parse_mode_html(self, bot, chat_id):
3541
message = bot.send_message(chat_id=chat_id, text=self.html_text,
3642
parse_mode=ParseMode.HTML)

tests/test_replykeyboardremove.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
# along with this program. If not, see [http://www.gnu.org/licenses/].
1919

2020
import pytest
21+
from flaky import flaky
2122

2223
from telegram import ReplyKeyboardRemove
2324

@@ -31,6 +32,8 @@ class TestReplyKeyboardRemove(object):
3132
remove_keyboard = True
3233
selective = True
3334

35+
@flaky(3, 1)
36+
@pytest.mark.timeout(10)
3437
def test_send_message_with_reply_keyboard_remove(self, bot, chat_id, reply_keyboard_remove):
3538
message = bot.send_message(chat_id, 'Text', reply_markup=reply_keyboard_remove)
3639

tests/test_updater.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def test(*args, **kwargs):
103103
monkeypatch.setattr('telegram.Bot.set_webhook', lambda *args, **kwargs: True)
104104
updater.dispatcher.add_error_handler(self.error_handler)
105105
updater.start_polling(0.01)
106-
assert self.err_handler_called.wait(0.5) is not True
106+
assert self.err_handler_called.wait(1) is not True
107107

108108
# NOTE: This test might hit a race condition and fail (though the 0.5 seconds delay above
109109
# should work around it).

0 commit comments

Comments
 (0)