Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[loadgroup] How to make one group always run in gw0 #1176

Open
pppppino opened this issue Feb 8, 2025 · 0 comments
Open

[loadgroup] How to make one group always run in gw0 #1176

pppppino opened this issue Feb 8, 2025 · 0 comments

Comments

@pppppino
Copy link

pppppino commented Feb 8, 2025

I am using pytest-xdist for parallel test execution, and I have grouped my test classes into two groups using the @pytest.mark.xdist_group("group1") and @pytest.mark.xdist_group("group2") decorators.

I then use the -n 2 and --dist loadgroup options to distribute tests by their groups, which works as expected by ensuring tests from the same xdist_group are grouped together.

However, I am facing an issue where the distribution of test groups across workers is not deterministic. The following two scenarios are possible:

Scenario 1:
gw0 runs all tests decorated with @pytest.mark.xdist_group("group1"), and gw1 runs all tests decorated with @pytest.mark.xdist_group("group2").

Scenario 2:
gw0 runs all tests decorated with @pytest.mark.xdist_group("group2"), and gw1 runs all tests decorated with @pytest.mark.xdist_group("group1").

This randomness in the worker assignment is problematic for my use case.

I want to ensure that all tests marked with group1 are always assigned to gw0 and all tests marked with group2 are always assigned to gw1, with no random distribution or switching of the groups between workers.

Is there a recommended way to enforce this specific assignment of tests to workers with pytest-xdist?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant