From 2ca1ce27624363040820408147355f742eb40547 Mon Sep 17 00:00:00 2001 From: Harshil <37377066+harshil21@users.noreply.github.com> Date: Sun, 19 May 2024 02:18:27 -0400 Subject: [PATCH] Remove xdist_group marker from tests --- tests/auxil/pytest_classes.py | 8 ++------ tests/test_bot.py | 32 +++++++------------------------- 2 files changed, 9 insertions(+), 31 deletions(-) diff --git a/tests/auxil/pytest_classes.py b/tests/auxil/pytest_classes.py index 5586a8ea0..20ba32c9e 100644 --- a/tests/auxil/pytest_classes.py +++ b/tests/auxil/pytest_classes.py @@ -36,12 +36,8 @@ def _get_bot_user(token: str) -> User: # This is important in e.g. bot equality tests. The other parameters like first_name don't # matter as much. In the future we may provide a way to get all the correct info from the token user_id = int(token.split(":")[0]) - first_name = bot_info.get( - "name", - ) - username = bot_info.get( - "username", - ).strip("@") + first_name = bot_info.get("name") + username = bot_info.get("username").strip("@") return User( user_id, first_name, diff --git a/tests/test_bot.py b/tests/test_bot.py index 34f25e6ce..80cc0e623 100644 --- a/tests/test_bot.py +++ b/tests/test_bot.py @@ -2808,7 +2808,6 @@ class TestBotWithRequest: async def test_edit_reply_markup_inline(self): pass - @pytest.mark.xdist_group("getUpdates_and_webhook") # TODO: Actually send updates to the test bot so this can be tested properly async def test_get_updates(self, bot): await bot.delete_webhook() # make sure there is no webhook set if webhook tests failed @@ -2875,7 +2874,6 @@ class TestBotWithRequest: await bot.get_updates(read_timeout=read_timeout, timeout=timeout) assert caught_read_timeout == expected - @pytest.mark.xdist_group("getUpdates_and_webhook") @pytest.mark.parametrize("use_ip", [True, False]) # local file path as file_input is tested below in test_set_webhook_params @pytest.mark.parametrize("file_input", ["bytes", "file_handle"]) @@ -3013,10 +3011,8 @@ class TestBotWithRequest: protected = await default_bot.send_game(chat_id, "test_game", protect_content=val) assert protected.has_protected_content is val - @pytest.mark.xdist_group("game") @xfail - async def test_set_game_score_1(self, bot, chat_id): - # NOTE: numbering of methods assures proper order between test_set_game_scoreX methods + async def test_set_game_score_and_high_scores(self, bot, chat_id): # First, test setting a score. game_short_name = "test_game" game = await bot.send_game(chat_id, game_short_name) @@ -3033,10 +3029,6 @@ class TestBotWithRequest: assert message.game.animation.file_unique_id == game.game.animation.file_unique_id assert message.game.text != game.game.text - @pytest.mark.xdist_group("game") - @xfail - async def test_set_game_score_2(self, bot, chat_id): - # NOTE: numbering of methods assures proper order between test_set_game_scoreX methods # Test setting a score higher than previous game_short_name = "test_game" game = await bot.send_game(chat_id, game_short_name) @@ -3056,10 +3048,6 @@ class TestBotWithRequest: assert message.game.animation.file_unique_id == game.game.animation.file_unique_id assert message.game.text == game.game.text - @pytest.mark.xdist_group("game") - @xfail - async def test_set_game_score_3(self, bot, chat_id): - # NOTE: numbering of methods assures proper order between test_set_game_scoreX methods # Test setting a score lower than previous (should raise error) game_short_name = "test_game" game = await bot.send_game(chat_id, game_short_name) @@ -3071,10 +3059,6 @@ class TestBotWithRequest: user_id=chat_id, score=score, chat_id=game.chat_id, message_id=game.message_id ) - @pytest.mark.xdist_group("game") - @xfail - async def test_set_game_score_4(self, bot, chat_id): - # NOTE: numbering of methods assures proper order between test_set_game_scoreX methods # Test force setting a lower score game_short_name = "test_game" game = await bot.send_game(chat_id, game_short_name) @@ -3099,9 +3083,6 @@ class TestBotWithRequest: game2 = await bot.send_game(chat_id, game_short_name) assert str(score) in game2.game.text - @pytest.mark.xdist_group("game") - @xfail - async def test_get_game_high_scores(self, bot, chat_id): # We need a game to get the scores for game_short_name = "test_game" game = await bot.send_game(chat_id, game_short_name) @@ -3767,9 +3748,10 @@ class TestBotWithRequest: ) msg1, msg2 = await tasks - copy_messages = await bot.copy_messages( - chat_id, from_chat_id=chat_id, message_ids=(msg1.message_id, msg2.message_id) - ) + ids = [msg1.message_id, msg2.message_id] + ids.sort() # TG requires the ids to be in ascending + + copy_messages = await bot.copy_messages(chat_id, from_chat_id=chat_id, message_ids=ids) assert isinstance(copy_messages, tuple) tasks = asyncio.gather( @@ -3781,8 +3763,8 @@ class TestBotWithRequest: forward_msg1 = temp_msg1.reply_to_message forward_msg2 = temp_msg2.reply_to_message - assert forward_msg1.text == msg1.text - assert forward_msg2.text == msg2.text + assert forward_msg1.text in (msg1.text, msg2.text) + assert forward_msg2.text in (msg1.text, msg2.text) # Continue testing arbitrary callback data here with actual requests: async def test_replace_callback_data_send_message(self, cdc_bot, chat_id):