Repository navigation
Fix missing results for tests marked with xdist_group - #26293
Open
Usama (PSEUDO) (pseudo-usama) wants to merge 1 commit into
Open
Usama (PSEUDO) (pseudo-usama) wants to merge 1 commit into
Usama (PSEUDO) (pseudo-usama) wants to merge 1 commit into
Conversation
With --dist=loadgroup, pytest-xdist renames tests marked with xdist_group to "<test id>@<group>" on its workers. The pytest plugin sent results under these renamed ids, which don't match the ids found during discovery, so the Test Explorer showed no result for them. Remove the group suffix before building the test id that is sent back. Fixes microsoft#24935
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #24935
With
--dist=loadgroup, pytest-xdist renames every test marked with@pytest.mark.xdist_groupto<test id>@<group>on its workers, so that its scheduler can keep a group on one worker. The pytest plugin sent results under these renamed ids. Discovery runs without xdist, so the ids didn't match any test item and the Test Explorer showed no result for grouped tests, while ungrouped tests in the same run were fine.The plugin now removes the group suffix before building the id it sends back. It does this only for tests that have the
xdist_groupmarker, and only strips an@that comes after the parametrize id (the same way pytest-xdist reads the group name back), so ids liketest_email[user@example.com]keep their@.Testing
test_xdist_group_executionruns a file with grouped passing, failing, skipped and parametrized tests (one parameter id contains@) under-n 1 --dist=loadgroupand checks the result ids. It fails onmainwith...::test_grouped@group_aids and passes with this change. It's skipped on Windows because the test harness's named pipe accepts a single connection, and the xdist controller and worker both connect to it.remove_xdist_group_suffix.pytest-xdisttobuild/test-requirements.txtso that CI runs the new test.python python_files/tests/run_all.py: 233 passed, 2 skipped (macOS, Python 3.12, with pytest 8.4.2 and 9.2.0).ruff check,ruff format --checkand pyright 1.1.308 report nothing new.pytestmark)xdist_groupmarkers give clean ids, and that the ids sent during execution match therunIDs that discovery returns for the same file.Note for reviewers: under xdist the controller process also re-sends every result with a
<cwd>::<name>id, for all xdist runs, grouped or not. Those ids match no test, so the extension ignores them. I left that alone to keep this PR focused; the new test only compares the results sent with the file path.Suggested label:
bug