diff --git a/tests/test_sticker.py b/tests/test_sticker.py index 06acd7a3933..cc394a88f1e 100644 --- a/tests/test_sticker.py +++ b/tests/test_sticker.py @@ -18,6 +18,7 @@ # 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 os +from time import sleep import pytest from flaky import flaky @@ -214,9 +215,12 @@ def test_equality(self, sticker): assert hash(a) != hash(e) -@pytest.fixture(scope='class') +@pytest.fixture(scope='function') def sticker_set(bot): - return bot.get_sticker_set('test_by_{0}'.format(bot.username)) + ss = bot.get_sticker_set('test_by_{0}'.format(bot.username)) + if len(ss.stickers) > 100: + raise Exception('stickerset is growing too large.') + return ss class TestStickerSet(object): @@ -249,18 +253,25 @@ def test_sticker_set_to_dict(self, sticker_set): assert sticker_set_dict['contains_masks'] == sticker_set.contains_masks assert sticker_set_dict['stickers'][0] == sticker_set.stickers[0].to_dict() + @flaky(3,1) + @pytest.mark.timeout(10) def test_bot_methods_1(self, bot, sticker_set): with open('tests/data/telegram_sticker.png', 'rb') as f: file = bot.upload_sticker_file(95205500, f) assert file assert bot.add_sticker_to_set(95205500, sticker_set.name, file.file_id, '😄') - @pytest.mark.xfail(raises=BadRequest, reason='STICKERSET_NOT_MODIFIED errors on deletion') + @flaky(3,1) + @pytest.mark.timeout(10) def test_bot_methods_2(self, bot, sticker_set): - updated_sticker_set = bot.get_sticker_set(sticker_set.name) - assert len(updated_sticker_set.stickers) > 1 # Otherwise test_bot_methods_1 failed - file_id = updated_sticker_set.stickers[-1].file_id - assert bot.set_sticker_position_in_set(file_id, len(updated_sticker_set.stickers) - 1) + file_id = 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(self, bot, sticker_set): + sleep(1) + file_id = sticker_set.stickers[-1].file_id assert bot.delete_sticker_from_set(file_id) def test_equality(self):
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: