2

By debugging a Python code in VS Code I want to step into routines of matplotlib package. By right mouse click I can open the code definition in the package source code, but I cannot step into it during debugging.

I use the newest VS Code with Pylance and Python extensions from Microsoft:

Version: 1.74.2 (system setup) Commit: e8a3071ea4344d9d48ef8a4df2c097372b0c5161 Date: 2022-12-20T10:29:14.590Z Electron: 19.1.8 Chromium: 102.0.5005.167 Node.js: 16.14.2 V8: 10.2.154.15-electron.0 OS: Windows_NT x64 10.0.18363 Sandboxed: No

Python 3.10.5 64-bit

Following several hints on Stack overflow I created a launch.json file in the workspace.vscode program directory and added a new configuration:

        {
            "name": "Debug Unit Test",
            "type": "python",
            "request": "test",
            "justMyCode": false
        }

I expected that upon debugging using the new configuration "Debug Unit Test" I can then step into external code, but it was not the case. Actually, the "test" value in "request" tag is marked as not accepted. I also tried "launch" there, but it also did not help.

Following another hint I also tried

        {
            "name": "Debug Unit Test",
            "type": "python",
            "request": "launch",
            "debugOptions": ["DebugStdLib"],
            "justMyCode": false
        }

The "debugOptions" property is however, not allowed.

I also searched for justMyCode parameter in VS Code settings and found only for Jupyter extension, not for Python.

Is it possible that VS Code discontinued this option for Python debugging??

1 Answer 1

4

Looking at the documentation it appears you need to add the following configuration:

{ 
  "name": "Python: Debug Tests",
  "type": "python",
  "request": "launch",
  "program": "${file}",
  "purpose": ["debug-test"],
  "console": "integratedTerminal",
  "justMyCode": false
}

I had the same issue but after adding the above to my launch.json I could step into code other than my own.

https://code.visualstudio.com/docs/python/testing#_debug-tests

Sign up to request clarification or add additional context in comments.

2 Comments

Hours it took me to find this. VSCode settings stuff is so difficult to get right. Thanks!
long live stackoverflow, I was following the docs and it didnt work because the doc has a newer config that my vscode hasnt adapted to yet , thanks mann

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.