pytest-dev / pytest-dev/pytest-xdist
Reason is displayed only once when tests are skipped dynamically with item.add_marker(pytest.mark.skip(reason))
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.9k
- Forks
- 287
- Avg merge
- 9h 30m
- Merged PRs (30d)
- 2
Description
After adding skip markers dynamically to tests based on a certain condition, as explained in the pytest documentation here, xdist displays the reason only once on the test result summary if running with multiple workers instead of displaying for each skipped test.
Suppose you have a code like below in conftest.py:
def pytest_collection_modifyitems(items, config):
for item in items:
if condition_to_skip_is_met():
reason = f"Cannot run {item.nodeid} because you didn't configure everything."
item.add_marker(pytest.mark.skip(reason))
The results are like below:
Launching pytest with arguments -n 3 tests/test_billing.py::TestConfig in /home/marco/my_tests
============================= test session starts ==============================
gw0 I / gw1 I / gw2 I
[gw0] linux Python 3.7.12 cwd: /home/marco/my_tests
[gw1] linux Python 3.7.12 cwd: /home/marco/my_tests
[gw2] linux Python 3.7.12 cwd: /home/marco/my_tests
[gw1] Python 3.7.12 (default, Dec 13 2021, 12:39:51) -- [GCC 9.3.0]
[gw0] Python 3.7.12 (default, Dec 13 2021, 12:39:51) -- [GCC 9.3.0]
[gw2] Python 3.7.12 (default, Dec 13 2021, 12:39:51) -- [GCC 9.3.0]
gw0 [8] / gw1 [8] / gw2 [8]
scheduling tests via LoadScheduling
tests/test_billing.py::TestConfig::test_config3
tests/test_billing.py::TestConfig::test_config2
tests/test_billing.py::TestConfig::test_config1
[gw2] [ 12%] PASSED tests/test_billing.py::TestConfig::test_config3
[gw0] [ 25%] PASSED tests/test_billing.py::TestConfig::test_config2
[gw1] [ 37%] PASSED tests/test_billing.py::TestConfig::test_config1
tests/test_billing.py::TestConfig::test_config5[2]
tests/test_billing.py::TestConfig::test_config5[1]
tests/test_billing.py::TestConfig::test_config4
[gw2] [ 50%] SKIPPED tests/test_billing.py::TestConfig::test_config5[2]
[gw0] [ 62%] SKIPPED tests/test_billing.py::TestConfig::test_config5[1]
[gw1] [ 75%] SKIPPED tests/test_billing.py::TestConfig::test_config4
Skipped: Cannot run tests/test_billing.py::TestConfig::test_config4 because you didn't configure everything.
tests/test_billing.py::TestConfig::test_config5[4]
tests/test_billing.py::TestConfig::test_config5[3]
[gw0] [ 87%] SKIPPED tests/test_billing.py::TestConfig::test_config5[4]
[gw2] [100%] SKIPPED tests/test_billing.py::TestConfig::test_config5[3]
========================= 3 passed, 5 skipped in 1.01s =========================
Process finished with exit code 0
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the example from conftest.py, using pytest_collection_modifyitems with dynamically added skip markers and xdist with -n 3. Trace the skipped-test reporting and summary handling; done means every dynamically skipped test displays its own reason in the output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100