Tests are skipped with pytest-xdist
See original GitHub issuepytest-dependency does not seem to behave well when using pytest-xdist. Some tests are skipped when they should not be. Let’s see how to quickly reproduce the bug:
test_foobar.py
import pytest
@pytest.mark.dependency()
def test_a():
pass
@pytest.mark.dependency(depends=["test_a"])
def test_b():
pass
console
virtualenv env
./env/bin/pip install pytest
./env/bin/pip install pytest-xdist
./env/bin/pip install pytest-dependency
./env/bin/pytest -n auto test_foobar.py
output
pytest test_foobar.py -n auto
============================= test session starts ==============================
platform linux -- Python 3.6.1, pytest-3.1.3, py-1.4.34, pluggy-0.4.0
rootdir: /home/eloi/dev/dependency-test, inifile:
plugins: xdist-1.18.1, dependency-0.2
gw0 [2] / gw1 [2] / gw2 [2] / gw3 [2]
scheduling tests via LoadScheduling
s.
===================== 1 passed, 1 skipped in 0.31 seconds ======================
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
py.test with xdist skipping all the tests with -n > 1
I have submitted to py.test's bugtracker a suggestion to make xdist sort parametrizations for comparison to avoid this problem.
Read more >Using pytest-order with other pytest plugins - GitHub Pages
The pytest-dependency plugin also manages dependencies between tests (skips tests that depend on skipped or failed tests), but doesn't do any ordering.
Read more >Running pytest in the Cloud for Fun and Profit | by Meadowrun
We'll also skip tests marked as slow, network, or db, following the logic in ... Pandas recommends running pytest-xdist with 4 workers in...
Read more >Testing — transformers 3.3.0 documentation - Hugging Face
pytest -xdist provides a very useful feature of detecting all failed tests, ... Here is how to skip all tests in a module...
Read more >Testing Python in Visual Studio Code
(If you're already familiar with unit testing, you can skip to the ... running tests in parallel with pytest is available through the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I documented the incompatibility with the parallelization in pytest-xdist and closed this issue. However, this is not the full story: pytest-xdist 1.19 added distributing mode
loadscope
and 1.21 addedloadfile
. Both distributing modes are compatible with pytest-dependency under certain conditions. But these distributing modes are marked experimental in pytest-xdist. I will wait for them to become stable before documenting this option.@RKrahl Can we perhaps piggyback off of
--dist loadgroup
? If we make every connected test belong to their own group, that seems to compatibilize the interaction between the two packages, no?