Skip to content

Commit bd3cdbc

Browse files
authored
Update pytest-xdist Usage (python-telegram-bot#4491)
1 parent 9709c03 commit bd3cdbc

2 files changed

Lines changed: 6 additions & 25 deletions

File tree

.github/workflows/unit_tests.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
python -W ignore -m pip install -U pytest-cov
3838
python -W ignore -m pip install .
3939
python -W ignore -m pip install -r requirements-unit-tests.txt
40-
python -W ignore -m pip install pytest-xdist[psutil]
40+
python -W ignore -m pip install pytest-xdist
4141
4242
- name: Test with pytest
4343
# We run 4 different suites here
@@ -63,10 +63,10 @@ jobs:
6363
# Test the rest
6464
export TEST_WITH_OPT_DEPS='true'
6565
pip install .[all]
66-
# `-n auto --dist loadfile` uses pytest-xdist to run each test file on a different CPU
67-
# worker. Increasing number of workers has little effect on test duration, but it seems
68-
# to increase flakyness, specially on python 3.7 with --dist=loadgroup.
69-
pytest -v --cov --cov-append -n auto --dist loadfile --junit-xml=.test_report_optionals_junit.xml
66+
# `-n auto --dist worksteal` uses pytest-xdist to run tests on multiple CPU
67+
# workers. Increasing number of workers has little effect on test duration, but it seems
68+
# to increase flakyness.
69+
pytest -v --cov --cov-append -n auto --dist worksteal --junit-xml=.test_report_optionals_junit.xml
7070
main_status=$?
7171
# exit with non-zero status if any of the two pytest runs failed
7272
exit $(( ${opt_dep_status} || ${main_status} ))

tests/test_bot.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3007,7 +3007,6 @@ async def test_edit_reply_markup(self, bot, message):
30073007
async def test_edit_reply_markup_inline(self):
30083008
pass
30093009

3010-
@pytest.mark.xdist_group("getUpdates_and_webhook")
30113010
# TODO: Actually send updates to the test bot so this can be tested properly
30123011
async def test_get_updates(self, bot):
30133012
await bot.delete_webhook() # make sure there is no webhook set if webhook tests failed
@@ -3074,7 +3073,6 @@ async def catch_timeouts(*args, **kwargs):
30743073
await bot.get_updates(read_timeout=read_timeout, timeout=timeout)
30753074
assert caught_read_timeout == expected
30763075

3077-
@pytest.mark.xdist_group("getUpdates_and_webhook")
30783076
@pytest.mark.parametrize("use_ip", [True, False])
30793077
# local file path as file_input is tested below in test_set_webhook_params
30803078
@pytest.mark.parametrize("file_input", ["bytes", "file_handle"])
@@ -3209,10 +3207,8 @@ async def test_send_game_default_protect_content(self, default_bot, chat_id, val
32093207
protected = await default_bot.send_game(chat_id, "test_game", protect_content=val)
32103208
assert protected.has_protected_content is val
32113209

3212-
@pytest.mark.xdist_group("game")
32133210
@xfail
3214-
async def test_set_game_score_1(self, bot, chat_id):
3215-
# NOTE: numbering of methods assures proper order between test_set_game_scoreX methods
3211+
async def test_set_game_score_and_high_scores(self, bot, chat_id):
32163212
# First, test setting a score.
32173213
game_short_name = "test_game"
32183214
game = await bot.send_game(chat_id, game_short_name)
@@ -3229,10 +3225,6 @@ async def test_set_game_score_1(self, bot, chat_id):
32293225
assert message.game.animation.file_unique_id == game.game.animation.file_unique_id
32303226
assert message.game.text != game.game.text
32313227

3232-
@pytest.mark.xdist_group("game")
3233-
@xfail
3234-
async def test_set_game_score_2(self, bot, chat_id):
3235-
# NOTE: numbering of methods assures proper order between test_set_game_scoreX methods
32363228
# Test setting a score higher than previous
32373229
game_short_name = "test_game"
32383230
game = await bot.send_game(chat_id, game_short_name)
@@ -3252,10 +3244,6 @@ async def test_set_game_score_2(self, bot, chat_id):
32523244
assert message.game.animation.file_unique_id == game.game.animation.file_unique_id
32533245
assert message.game.text == game.game.text
32543246

3255-
@pytest.mark.xdist_group("game")
3256-
@xfail
3257-
async def test_set_game_score_3(self, bot, chat_id):
3258-
# NOTE: numbering of methods assures proper order between test_set_game_scoreX methods
32593247
# Test setting a score lower than previous (should raise error)
32603248
game_short_name = "test_game"
32613249
game = await bot.send_game(chat_id, game_short_name)
@@ -3267,10 +3255,6 @@ async def test_set_game_score_3(self, bot, chat_id):
32673255
user_id=chat_id, score=score, chat_id=game.chat_id, message_id=game.message_id
32683256
)
32693257

3270-
@pytest.mark.xdist_group("game")
3271-
@xfail
3272-
async def test_set_game_score_4(self, bot, chat_id):
3273-
# NOTE: numbering of methods assures proper order between test_set_game_scoreX methods
32743258
# Test force setting a lower score
32753259
game_short_name = "test_game"
32763260
game = await bot.send_game(chat_id, game_short_name)
@@ -3295,9 +3279,6 @@ async def test_set_game_score_4(self, bot, chat_id):
32953279
game2 = await bot.send_game(chat_id, game_short_name)
32963280
assert str(score) in game2.game.text
32973281

3298-
@pytest.mark.xdist_group("game")
3299-
@xfail
3300-
async def test_get_game_high_scores(self, bot, chat_id):
33013282
# We need a game to get the scores for
33023283
game_short_name = "test_game"
33033284
game = await bot.send_game(chat_id, game_short_name)

0 commit comments

Comments
 (0)