pytest-xdist
pytest-xdist copied to clipboard
Is there a way to run groups in parallel
test.py
import pytest
import time
@pytest.mark.xdist_group(name="group1")
def test_1_1():
time.sleep(5)
assert True
@pytest.mark.xdist_group(name="group1")
def test_1_2():
time.sleep(5)
assert True
pytest -n auto --dist loadgroup test.py
Is there a way to get group1 to run in parallel and take ~5s rather than ~10s it takes with the above setup
The purpose of "grouping" is to force tests to run in the same worker... if you want them to run in parallel, just don't put them into the same group.
What are you trying to accomplish?
@nicoddemus, thanks for your response. For example, If you have multiple tests in a group dependent on one test in the same group, running with --dist loadgroup runs all tests in sequnece.
I know pytest-order is a different plugin but the below example could help explain my question better:
import pytest
import time
@pytest.mark.xdist_group(name="group1")
def test_1_1():
time.sleep(5)
assert True
@pytest.mark.xdist_group(name="group1")
@pytest.mark.order(after="test_1_1")
def test_1_2():
time.sleep(5)
assert True
@pytest.mark.xdist_group(name="group1")
@pytest.mark.order(after="test_1_1")
def test_1_3():
time.sleep(5)
assert True
@pytest.mark.xdist_group(name="group1")
@pytest.mark.order(after="test_1_1")
def test_1_4():
time.sleep(5)
assert True
3 tests are dependent on 1 (test_1_1) in a group but they could run in parallel after test_1_1 completes but currently with --dist=loadgroup all tests run in sequence.
is there a way to get ordered parallelism in a group?