microsoft / vscode-python-debugger

Python debugger (debugpy) extension for VS Code.
https://marketplace.visualstudio.com/items?itemName=ms-python.debugpy
MIT License
40 stars 17 forks source link

Read launch config from devcontainer file #354

Open rubensa opened 1 month ago

rubensa commented 1 month ago

Related to this and this.

Looks like there is a missing piece on getting launch configurations when debugging python tests through the GUI.

I'm using VSCode devcontainers and have a launch configuration in .devcontainer/devcontainer.json file, like:

{
  "customizations": {
    "vscode": {
      "settings": {
        "launch": {
          "configurations": [
            {
              "name": "Python Debugger: Current File",
              "type": "debugpy",
              "request": "launch",
              "program": "${file}",
              "purpose": [
                "debug-test"
              ],
              "justMyCode": false,
              "console": "integratedTerminal",
              "env": {
                "ENVIRONMENT": "test"
              },
              "envFile": "${workspaceFolder}/.devcontainer/.env.local"
            }
          ]
        }
      }
    }
  }
}

The launch configuration is applied when using Run and Debug but not on Testing.

As a workaround, I can "duplicate" the configuration in .vscode/launch.json file and then it is picked up both in Run and Debug and Testing.