Skip to content

Join multiple xdist_group #1201

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

Merged
merged 13 commits into from
May 15, 2025
Merged

Join multiple xdist_group #1201

merged 13 commits into from
May 15, 2025

Conversation

ygorpontelo
Copy link
Contributor

Adressing #1200

Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ygorpontelo!

Besides the changes requested, we need:

  • Tests.
  • Update the documentation explaining that multiple xdist_group markers are merged together.

@ygorpontelo ygorpontelo requested a review from nicoddemus May 10, 2025 18:55
Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ygorpontelo for following up!

Left a few more suggestions, please take a look!

@ygorpontelo
Copy link
Contributor Author

Appreciate the feedback @nicoddemus! Anything else we should update?

@ygorpontelo ygorpontelo requested a review from nicoddemus May 12, 2025 19:52
Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

@ygorpontelo ygorpontelo May 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. The underscore is just to join them, so it would form something like this: group_1 + group_2 = group_1_group_2.

  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 "::".

  3. 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 = (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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....}

@ygorpontelo
Copy link
Contributor Author

@nicoddemus just need to merge now.

@nicoddemus nicoddemus merged commit 65de0ab into pytest-dev:master May 15, 2025
21 checks passed
@nicoddemus
Copy link
Member

Thanks again @ygorpontelo!

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

Successfully merging this pull request may close these issues.

3 participants