From 401c707d9d4b46893e0273ea9b82e6ff8957d7a5 Mon Sep 17 00:00:00 2001 From: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com> Date: Sat, 20 Sep 2025 11:12:11 -0700 Subject: [PATCH 1/2] Add command for copying test ID in Python testing gutter --- package.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/package.json b/package.json index 0530726310f2..9bb3886d4fdc 100644 --- a/package.json +++ b/package.json @@ -1244,6 +1244,13 @@ "when": "controllerId == 'python-tests'" } ], + "testing/item/gutter": [ + { + "command": "python.copyTestId", + "group": "navigation", + "when": "controllerId == 'python-tests'" + } + ], "commandPalette": [ { "category": "Python", From b8388ececbd8664d3da4f1d10d2a59c35824820e Mon Sep 17 00:00:00 2001 From: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com> Date: Sat, 20 Sep 2025 11:16:15 -0700 Subject: [PATCH 2/2] documentation --- .github/instructions/testing_feature_area.instructions.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/instructions/testing_feature_area.instructions.md b/.github/instructions/testing_feature_area.instructions.md index 9036ab4e3acd..038dc1025ea5 100644 --- a/.github/instructions/testing_feature_area.instructions.md +++ b/.github/instructions/testing_feature_area.instructions.md @@ -173,9 +173,15 @@ The adapters in the extension don't implement test discovery/run logic themselve - Debug adapter/resolver code in the extension's debugger modules may also be used when attaching to Django or test subprocesses. - Commands and configuration - The Test Controller wires commands that appear in the Test Explorer and editor context menus (see `package.json` contributes `commands`) and listens to configuration changes filtered by `python.testing` in `src/client/testing/main.ts`. +- The "Copy Test ID" command (`python.copyTestId`) can be accessed from both the Test Explorer context menu (`testing/item/context`) and the editor gutter icon context menu (`testing/item/gutter`). This command copies test identifiers to the clipboard in the appropriate format for the active test framework (pytest path format or unittest module.class.method format). - Execution factory & activated environments - Adapters use the extension `ExecutionFactory` to spawn subprocesses in an activated interpreter (so the user's venv/conda is used). This involves the extension's internal environment execution APIs and sometimes `envExt` helpers when the external environment extension is present. ## Learnings - Never await `showErrorMessage()` calls in test execution adapters as it blocks the test UI thread and freezes the Test Explorer (1) +- VS Code test-related context menus are contributed to using both `testing/item/context` and `testing/item/gutter` menu locations in package.json for full coverage (1) + +``` + +```