question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tests are skipped with pytest-xdist

See original GitHub issue

pytest-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:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
RKrahlcommented, Dec 26, 2017

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 added loadfile. 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.

0reactions
pkochcommented, Mar 12, 2022

@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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found