Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Update pytest-xdist Usage #4491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -63,10 +63,10 @@ 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
# 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 --junit-xml=.test_report_optionals_junit.xml
# `-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 --junit-xml=.test_report_optionals_junit.xml
main_status=$?
# exit with non-zero status if any of the two pytest runs failed
exit $(( ${opt_dep_status} || ${main_status} ))
Expand Down
21 changes: 1 addition & 20 deletions tests/test_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3007,7 +3007,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
Expand Down Expand Up @@ -3074,7 +3073,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"])
Expand Down Expand Up @@ -3209,10 +3207,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)
Expand All @@ -3229,10 +3225,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)
Expand All @@ -3252,10 +3244,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)
Expand All @@ -3267,10 +3255,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)
Expand All @@ -3295,9 +3279,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)
Expand Down
Loading