From d81180162b3d58a2ab52494af79e5d356d8574bc Mon Sep 17 00:00:00 2001 From: Harshil <37377066+harshil21@users.noreply.github.com> Date: Sun, 19 May 2024 08:18:27 +0200 Subject: [PATCH 1/3] Remove xdist_group marker from tests --- tests/test_bot.py | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/tests/test_bot.py b/tests/test_bot.py index 54fa28f11cb..50fb15d64eb 100644 --- a/tests/test_bot.py +++ b/tests/test_bot.py @@ -2998,7 +2998,6 @@ async def test_edit_reply_markup(self, bot, message): 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 @@ -3065,7 +3064,6 @@ async def catch_timeouts(*args, **kwargs): 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"]) @@ -3200,10 +3198,8 @@ async def test_send_game_default_protect_content(self, default_bot, chat_id, val 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) @@ -3220,10 +3216,6 @@ async def test_set_game_score_1(self, bot, chat_id): 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) @@ -3243,10 +3235,6 @@ async def test_set_game_score_2(self, bot, chat_id): 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) @@ -3258,10 +3246,6 @@ async def test_set_game_score_3(self, bot, chat_id): 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) @@ -3286,9 +3270,6 @@ async def test_set_game_score_4(self, bot, chat_id): 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) From e2879abd511125f19a003fb175d9bf631e7d685f Mon Sep 17 00:00:00 2001 From: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com> Date: Sat, 21 Sep 2024 15:19:14 +0200 Subject: [PATCH 2/3] Use worksteal configuration for pytest-xdist --- .github/workflows/unit_tests.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index fc9925c0806..65b862d8f17 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -37,7 +37,7 @@ jobs: python -W ignore -m pip install -U pytest-cov python -W ignore -m pip install . python -W ignore -m pip install -r requirements-unit-tests.txt - python -W ignore -m pip install pytest-xdist[psutil] + python -W ignore -m pip install pytest-xdist - name: Test with pytest # We run 4 different suites here @@ -66,11 +66,11 @@ jobs: # Test the rest export TEST_WITH_OPT_DEPS='true' pip install .[all] - # `-n auto --dist loadfile` uses pytest-xdist to run each test file on a different CPU + # `-n auto --dist worksteal` uses pytest-xdist to run each test file on a different CPU # worker. Increasing number of workers has little effect on test duration, but it seems - # to increase flakyness, specially on python 3.7 with --dist=loadgroup. - pytest -v --cov --cov-append -n auto --dist loadfile - pytest -v --cov --cov-append -n auto --dist loadfile --lf --lfnf=none --junit-xml=.test_report_optionals.xml + # to increase flakyness. + pytest -v --cov --cov-append -n auto --dist worksteal + pytest -v --cov --cov-append -n auto --dist worksteal --lf --lfnf=none --junit-xml=.test_report_optionals.xml main_status=$(( $? == 5 ? 0 : $? )) # exit with non-zero status if any of the two pytest runs failed exit $(( ${opt_dep_status} || ${main_status} )) From 319ff1db9e99f0581c307a8faa7f2b1422cbafad Mon Sep 17 00:00:00 2001 From: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com> Date: Sat, 21 Sep 2024 17:14:42 +0200 Subject: [PATCH 3/3] Update .github/workflows/unit_tests.yml Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com> --- .github/workflows/unit_tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 65b862d8f17..7c6597544ef 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -66,8 +66,8 @@ jobs: # Test the rest export TEST_WITH_OPT_DEPS='true' pip install .[all] - # `-n auto --dist worksteal` uses pytest-xdist to run each test file on a different CPU - # worker. Increasing number of workers has little effect on test duration, but it seems + # `-n auto --dist worksteal` uses pytest-xdist to run tests on multiple CPU + # workers. Increasing number of workers has little effect on test duration, but it seems # to increase flakyness. pytest -v --cov --cov-append -n auto --dist worksteal pytest -v --cov --cov-append -n auto --dist worksteal --lf --lfnf=none --junit-xml=.test_report_optionals.xml