Python test debugging falls back to default launch configuration after running custom debug-test
configuration once
#22530
Labels
bug
Issue identified by VS Code Team member as probable bug
triage-needed
Needs assignment to the proper sub-team
Type: Bug
Behaviour
Expected vs. Actual
[Expected] When debugging a test using a custom launch configuration that includes
"purpose": [ "debug-test" ]
, I expect subsequent debugging sessions to continue using the same, custom launch configuration. [Actual] However, after debugging a test for the first time, any subsequent test debugging (for any test) will fall back to the default launch configuration, i.e., as if the custom launch configuration was not properly configured.My own investigation
I have debugged the extension and followed the breadcrumbs when running through the steps to reproduce the issue, as written in the section below. Here are my findings:
When debugging a test, the custom launch configuration is read from a
*.code-workspace
file by invokinggetConfiguration
in the code line below:vscode-python/src/client/debugger/extension/configuration/launch.json/launchJsonReader.ts
Line 15 in eb96141
When running the debugger for the first time, the call to
getConfiguration
will return the correct launch configuration found in the.code-workspace
file (e.g., the one in the section below). Looking at the variables panel, we can see that the first timegetConfiguration
is called, it returns everything correctly.However, the second time it's invoked, the field
purpose
is empty and some other fields show up:This means that, the following
if
branch inreadDebugConfig
will always be false, thus returningundefined
sincecfg.request === 'test'
and(cfg as LaunchRequestArguments).purpose?.includes(DebugPurpose.DebugTest))
will always befalse
:vscode-python/src/client/testing/common/debugLauncher.ts
Lines 117 to 129 in eb96141
Since
readDebugConfig
returnsundefined
, the next code executed (below) will create a defaultdebugConfig
ingetLaunchArgs
. This explains why the second run uses the default launch configuration.vscode-python/src/client/testing/common/debugLauncher.ts
Lines 78 to 85 in eb96141
Steps to reproduce:
pytest
).DEBUG CONSOLE
and observe the windows available (see image below), there should be two:Python: Debug Tests
, i.e., the name of our custom configuration, andDebug Unit Test
, the default launch configuration in VSCode.Python
in theOutput panel
suggests that both debugging sessions used the custom launch configurationUsing launch configuration in workspace folder
.Diagnostic data
python.languageServer
setting: DefaultOutput for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)User Settings
Extension version: 2023.20.0
VS Code version: Code 1.84.2 (Universal) (1a5daa3a0231a0fbba4f14db7ec463cf99d7768e, 2023-11-09T10:52:33.687Z)
OS version: Darwin x64 22.6.0
Modes:
Remote OS version: Linux x64 5.4.259-180.361.amzn2int.x86_64
Remote OS version: Linux x64 5.4.259-180.361.amzn2int.x86_64
Remote OS version: Linux x64 5.4.259-180.361.amzn2int.x86_64
The text was updated successfully, but these errors were encountered: