From cc43aef64bc3501c08cc9e1641777ecd87b98e74 Mon Sep 17 00:00:00 2001 From: Bibo-Joshi Date: Fri, 28 May 2021 22:24:43 +0200 Subject: [PATCH] Fix Test Failing Due To Telegram Updates (#2537) * Update TestPhoto * try to fix test_idle again... * fix test_send_game due to photo size changes... Co-authored-by: Harshil --- tests/test_bot.py | 4 ++-- tests/test_photo.py | 10 +++++----- tests/test_updater.py | 6 ++++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/test_bot.py b/tests/test_bot.py index d1009c96a..ca2701f38 100644 --- a/tests/test_bot.py +++ b/tests/test_bot.py @@ -1242,8 +1242,8 @@ class TestBot: ) assert message.game.animation.file_id != '' # We added some test bots later and for some reason the file size is not the same for them - # so we accept two different sizes here. Shouldn't be too much of - assert message.game.photo[0].file_size in [851, 4928] + # so we accept three different sizes here. Shouldn't be too much of + assert message.game.photo[0].file_size in [851, 4928, 850] @flaky(3, 1) @pytest.mark.parametrize( diff --git a/tests/test_photo.py b/tests/test_photo.py index 3fb9e9440..0f2b3e608 100644 --- a/tests/test_photo.py +++ b/tests/test_photo.py @@ -60,8 +60,8 @@ def photo(_photo): class TestPhoto: - width = 800 - height = 800 + width = 320 + height = 320 caption = 'PhotoTest - *Caption*' photo_file_url = 'https://python-telegram-bot.org/static/testfiles/telegram.jpg' file_size = 29176 @@ -85,8 +85,8 @@ class TestPhoto: # the compression method and it's not really our job anyway ... assert photo.width == self.width assert photo.height == self.height - assert thumb.width == 320 - assert thumb.height == 320 + assert thumb.width == 90 + assert thumb.height == 90 @flaky(3, 1) def test_send_photo_all_args(self, bot, chat_id, photo_file, thumb, photo): @@ -386,7 +386,7 @@ class TestPhoto: def test_resend(self, bot, chat_id, photo): message = bot.send_photo(chat_id=chat_id, photo=photo.file_id) - thumb, photo = message.photo + thumb, photo, _ = message.photo assert isinstance(message.photo[0], PhotoSize) assert isinstance(message.photo[0].file_id, str) diff --git a/tests/test_updater.py b/tests/test_updater.py index f9dc0ceac..ab7eccd84 100644 --- a/tests/test_updater.py +++ b/tests/test_updater.py @@ -484,8 +484,10 @@ class TestUpdater: # There is a chance of a conflict when getting updates since there can be many tests # (bots) running simultaneously while testing in github actions. - if caplog.records[0].getMessage().startswith('Error while getting Updates: Conflict'): - caplog.records.pop() # For stability + for idx, log in enumerate(caplog.records): + if log.getMessage().startswith('Error while getting Updates: Conflict'): + caplog.records.pop(idx) # For stability + assert len(caplog.records) == 2, caplog.records rec = caplog.records[-2] assert rec.getMessage().startswith(f'Received signal {signal.SIGTERM}')