Join multiple xdist_group#1201
Conversation
There was a problem hiding this comment.
Thanks @ygorpontelo!
Besides the changes requested, we need:
- Tests.
- Update the documentation explaining that multiple
xdist_groupmarkers are merged together.
for more information, see https://pre-commit.ci
nicoddemus
left a comment
There was a problem hiding this comment.
Thanks @ygorpontelo for following up!
Left a few more suggestions, please take a look!
Co-authored-by: Bruno Oliveira <bruno@soliv.dev>
Co-authored-by: Bruno Oliveira <bruno@soliv.dev>
Co-authored-by: Bruno Oliveira <bruno@soliv.dev>
for more information, see https://pre-commit.ci
|
Appreciate the feedback @nicoddemus! Anything else we should update? |
nicoddemus
left a comment
There was a problem hiding this comment.
Thanks @ygorpontelo!
@RonnyPfannschmidt would you like to do another review pass?
| test_file = """ | ||
| import pytest | ||
| @pytest.mark.xdist_group(name="b") | ||
| @pytest.mark.xdist_group(name="d") |
There was a problem hiding this comment.
What happens when group names get dashes underscores or other characters
In particular groupd with underscores are now ambiguous
Also what happens when the same group name come up in different order
There was a problem hiding this comment.
We currently add all markers to a set, then sort them and join with _... I think this covers all cases correctly? Or do you have an example where this would cause problems?
There was a problem hiding this comment.
-
The underscore is just to join them, so it would form something like this: group_1 + group_2 = group_1_group_2.
-
If we want to have a unique separator to retrieve the original groups we can, but the marks still exist in the item, i just change the nodeid in this case. In any case, we can choose some other one, like "::".
-
I check if the name already exists, so every mark is unique and then sorted.Just seen nico changed to a set, neat!
| if not mark: | ||
| gnames: set[str] = set() | ||
| for mark in item.iter_markers("xdist_group"): | ||
| name = ( |
There was a problem hiding this comment.
The logic for getting the name of the mark seems involved enough to make it a function
A fun hack would be
def group_name_of(name,*k,**kw):
return name
groups = {group_name_of(*mark.args, **mark.kwargs) for mark in item.iter....}
|
@nicoddemus just need to merge now. |
|
Thanks again @ygorpontelo! |
Adressing #1200