mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-21 22:56:38 +01:00
Update pytest-xdist
Usage (#4491)
This commit is contained in:
parent
9709c03b35
commit
bd3cdbcdbd
2 changed files with 6 additions and 25 deletions
10
.github/workflows/unit_tests.yml
vendored
10
.github/workflows/unit_tests.yml
vendored
|
@ -37,7 +37,7 @@ jobs:
|
||||||
python -W ignore -m pip install -U pytest-cov
|
python -W ignore -m pip install -U pytest-cov
|
||||||
python -W ignore -m pip install .
|
python -W ignore -m pip install .
|
||||||
python -W ignore -m pip install -r requirements-unit-tests.txt
|
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
|
- name: Test with pytest
|
||||||
# We run 4 different suites here
|
# We run 4 different suites here
|
||||||
|
@ -63,10 +63,10 @@ jobs:
|
||||||
# Test the rest
|
# Test the rest
|
||||||
export TEST_WITH_OPT_DEPS='true'
|
export TEST_WITH_OPT_DEPS='true'
|
||||||
pip install .[all]
|
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 tests on multiple CPU
|
||||||
# worker. Increasing number of workers has little effect on test duration, but it seems
|
# workers. Increasing number of workers has little effect on test duration, but it seems
|
||||||
# to increase flakyness, specially on python 3.7 with --dist=loadgroup.
|
# to increase flakyness.
|
||||||
pytest -v --cov --cov-append -n auto --dist loadfile --junit-xml=.test_report_optionals_junit.xml
|
pytest -v --cov --cov-append -n auto --dist worksteal --junit-xml=.test_report_optionals_junit.xml
|
||||||
main_status=$?
|
main_status=$?
|
||||||
# exit with non-zero status if any of the two pytest runs failed
|
# exit with non-zero status if any of the two pytest runs failed
|
||||||
exit $(( ${opt_dep_status} || ${main_status} ))
|
exit $(( ${opt_dep_status} || ${main_status} ))
|
||||||
|
|
|
@ -3007,7 +3007,6 @@ class TestBotWithRequest:
|
||||||
async def test_edit_reply_markup_inline(self):
|
async def test_edit_reply_markup_inline(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@pytest.mark.xdist_group("getUpdates_and_webhook")
|
|
||||||
# TODO: Actually send updates to the test bot so this can be tested properly
|
# TODO: Actually send updates to the test bot so this can be tested properly
|
||||||
async def test_get_updates(self, bot):
|
async def test_get_updates(self, bot):
|
||||||
await bot.delete_webhook() # make sure there is no webhook set if webhook tests failed
|
await bot.delete_webhook() # make sure there is no webhook set if webhook tests failed
|
||||||
|
@ -3074,7 +3073,6 @@ class TestBotWithRequest:
|
||||||
await bot.get_updates(read_timeout=read_timeout, timeout=timeout)
|
await bot.get_updates(read_timeout=read_timeout, timeout=timeout)
|
||||||
assert caught_read_timeout == expected
|
assert caught_read_timeout == expected
|
||||||
|
|
||||||
@pytest.mark.xdist_group("getUpdates_and_webhook")
|
|
||||||
@pytest.mark.parametrize("use_ip", [True, False])
|
@pytest.mark.parametrize("use_ip", [True, False])
|
||||||
# local file path as file_input is tested below in test_set_webhook_params
|
# local file path as file_input is tested below in test_set_webhook_params
|
||||||
@pytest.mark.parametrize("file_input", ["bytes", "file_handle"])
|
@pytest.mark.parametrize("file_input", ["bytes", "file_handle"])
|
||||||
|
@ -3209,10 +3207,8 @@ class TestBotWithRequest:
|
||||||
protected = await default_bot.send_game(chat_id, "test_game", protect_content=val)
|
protected = await default_bot.send_game(chat_id, "test_game", protect_content=val)
|
||||||
assert protected.has_protected_content is val
|
assert protected.has_protected_content is val
|
||||||
|
|
||||||
@pytest.mark.xdist_group("game")
|
|
||||||
@xfail
|
@xfail
|
||||||
async def test_set_game_score_1(self, bot, chat_id):
|
async def test_set_game_score_and_high_scores(self, bot, chat_id):
|
||||||
# NOTE: numbering of methods assures proper order between test_set_game_scoreX methods
|
|
||||||
# First, test setting a score.
|
# First, test setting a score.
|
||||||
game_short_name = "test_game"
|
game_short_name = "test_game"
|
||||||
game = await bot.send_game(chat_id, game_short_name)
|
game = await bot.send_game(chat_id, game_short_name)
|
||||||
|
@ -3229,10 +3225,6 @@ class TestBotWithRequest:
|
||||||
assert message.game.animation.file_unique_id == game.game.animation.file_unique_id
|
assert message.game.animation.file_unique_id == game.game.animation.file_unique_id
|
||||||
assert message.game.text != game.game.text
|
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
|
# Test setting a score higher than previous
|
||||||
game_short_name = "test_game"
|
game_short_name = "test_game"
|
||||||
game = await bot.send_game(chat_id, game_short_name)
|
game = await bot.send_game(chat_id, game_short_name)
|
||||||
|
@ -3252,10 +3244,6 @@ class TestBotWithRequest:
|
||||||
assert message.game.animation.file_unique_id == game.game.animation.file_unique_id
|
assert message.game.animation.file_unique_id == game.game.animation.file_unique_id
|
||||||
assert message.game.text == game.game.text
|
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)
|
# Test setting a score lower than previous (should raise error)
|
||||||
game_short_name = "test_game"
|
game_short_name = "test_game"
|
||||||
game = await bot.send_game(chat_id, game_short_name)
|
game = await bot.send_game(chat_id, game_short_name)
|
||||||
|
@ -3267,10 +3255,6 @@ class TestBotWithRequest:
|
||||||
user_id=chat_id, score=score, chat_id=game.chat_id, message_id=game.message_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
|
# Test force setting a lower score
|
||||||
game_short_name = "test_game"
|
game_short_name = "test_game"
|
||||||
game = await bot.send_game(chat_id, game_short_name)
|
game = await bot.send_game(chat_id, game_short_name)
|
||||||
|
@ -3295,9 +3279,6 @@ class TestBotWithRequest:
|
||||||
game2 = await bot.send_game(chat_id, game_short_name)
|
game2 = await bot.send_game(chat_id, game_short_name)
|
||||||
assert str(score) in game2.game.text
|
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
|
# We need a game to get the scores for
|
||||||
game_short_name = "test_game"
|
game_short_name = "test_game"
|
||||||
game = await bot.send_game(chat_id, game_short_name)
|
game = await bot.send_game(chat_id, game_short_name)
|
||||||
|
|
Loading…
Reference in a new issue