Strip project scope prefix from IDs copied by "Copy test ID" - #26153
Open
Eduardo Villalpando Mello (edvilme) with Copilot wants to merge 3 commits into
Open
Eduardo Villalpando Mello (edvilme) with Copilot wants to merge 3 commits into
Eduardo Villalpando Mello (edvilme) with Copilot wants to merge 3 commits into
Conversation
Copilot started work on behalf of
Eduardo Villalpando Mello (edvilme)
September 16, 2026 23:04
View session
Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix copy test ID to remove 'file://' prefix
Strip project scope prefix from IDs copied by "Copy test ID"
Sep 16, 2026
Eduardo Villalpando Mello (edvilme)
approved these changes
Sep 17, 2026
Eduardo Villalpando Mello (edvilme)
marked this pull request as ready for review
September 17, 2026 16:39
Member
|
🔒 Automated review in progress — Bill Schnurr (@bschnurr) is auto-reviewing this PR. |
| if (testItem && typeof testItem.id === 'string') { | ||
| if (testItem.id.includes('\\') && testItem.id.indexOf('::') === -1) { | ||
| // Strip the project scope prefix (if any) so only the test id is copied. | ||
| const [, testId] = parseVsId(testItem.id); |
There was a problem hiding this comment.
Warning · Non-blocking recommendation
Could an unscoped pytest parameter ID contain @@vsc@@ (for example, tests/test_foo.py::test_value[value@@vsc@@suffix])? If so, parseVsId would treat it as project-scoped and copy only suffix]. Please ensure the scope prefix is validated before stripping it, and cover this parameterized-ID case.
Bill Schnurr (bschnurr)
approved these changes
Sep 17, 2026
Bill Schnurr (bschnurr)
left a comment
Member
There was a problem hiding this comment.
Approved via Review Center.
Copilot started work on behalf of
Eduardo Villalpando Mello (edvilme)
September 17, 2026 19:25
View session
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 #26092
"Copy test ID" copied the raw
TestItem.id, which since project scoping is{projectId}@@vsc@@{testId}, so users pastedfile:///path/to/workspace@@vsc@@/path/to/workspace/tests/unit/test_foo.py::test_barinstead of the test ID.Changes
src/client/testing/utils.ts:writeTestIdToClipboardnow normalizes the ID with the existingparseVsIdhelper before unittest detection/conversion, the pytest clipboard write, and logging.TestItem.idis not mutated and discovery/execution scoping is untouched — only the clipboard-facing value is normalized.parseVsIdreturns[undefined, vsId]for unscoped IDs, so legacy behavior and themodule.class.methodunittest formatting are preserved.src/test/testing/utils.unit.test.ts: this file was a top-level IIFE withtry/catch-swallowed assertions that mocha never registered as tests (and itsidToModuleClassMethodinputs had lost their backslash separators). Converted to asuite/testfile asserting the real clipboard contents via theMockClipboardfromsrc/test/vscode-mock.ts, with cases for project-scoped pytest IDs, parameterized IDs (test_pipe_single[False]preserved verbatim), Windows-style paths, legacy unscoped IDs, and project-scoped unittest IDs.