Skip to content

Commit cc43aef

Browse files
Fix Test Failing Due To Telegram Updates (python-telegram-bot#2537)
* Update TestPhoto * try to fix test_idle again... * fix test_send_game due to photo size changes... Co-authored-by: Harshil <[email protected]>
1 parent e2c6d60 commit cc43aef

3 files changed

Lines changed: 11 additions & 9 deletions

File tree

tests/test_bot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,8 +1242,8 @@ def test_send_game(self, bot, chat_id):
12421242
)
12431243
assert message.game.animation.file_id != ''
12441244
# We added some test bots later and for some reason the file size is not the same for them
1245-
# so we accept two different sizes here. Shouldn't be too much of
1246-
assert message.game.photo[0].file_size in [851, 4928]
1245+
# so we accept three different sizes here. Shouldn't be too much of
1246+
assert message.game.photo[0].file_size in [851, 4928, 850]
12471247

12481248
@flaky(3, 1)
12491249
@pytest.mark.parametrize(

tests/test_photo.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ def photo(_photo):
6060

6161

6262
class TestPhoto:
63-
width = 800
64-
height = 800
63+
width = 320
64+
height = 320
6565
caption = '<b>PhotoTest</b> - *Caption*'
6666
photo_file_url = 'https://python-telegram-bot.org/static/testfiles/telegram.jpg'
6767
file_size = 29176
@@ -85,8 +85,8 @@ def test_expected_values(self, photo, thumb):
8585
# the compression method and it's not really our job anyway ...
8686
assert photo.width == self.width
8787
assert photo.height == self.height
88-
assert thumb.width == 320
89-
assert thumb.height == 320
88+
assert thumb.width == 90
89+
assert thumb.height == 90
9090

9191
@flaky(3, 1)
9292
def test_send_photo_all_args(self, bot, chat_id, photo_file, thumb, photo):
@@ -386,7 +386,7 @@ def test(url, data, **kwargs):
386386
def test_resend(self, bot, chat_id, photo):
387387
message = bot.send_photo(chat_id=chat_id, photo=photo.file_id)
388388

389-
thumb, photo = message.photo
389+
thumb, photo, _ = message.photo
390390

391391
assert isinstance(message.photo[0], PhotoSize)
392392
assert isinstance(message.photo[0].file_id, str)

tests/test_updater.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,10 @@ def test_idle(self, updater, caplog):
484484

485485
# There is a chance of a conflict when getting updates since there can be many tests
486486
# (bots) running simultaneously while testing in github actions.
487-
if caplog.records[0].getMessage().startswith('Error while getting Updates: Conflict'):
488-
caplog.records.pop() # For stability
487+
for idx, log in enumerate(caplog.records):
488+
if log.getMessage().startswith('Error while getting Updates: Conflict'):
489+
caplog.records.pop(idx) # For stability
490+
assert len(caplog.records) == 2, caplog.records
489491

490492
rec = caplog.records[-2]
491493
assert rec.getMessage().startswith(f'Received signal {signal.SIGTERM}')

0 commit comments

Comments
 (0)