How to enter into imported package while debugging in VS code
As an example:
import os
import mdfreader
k123 = mdfreader.mdf("Test.mf4")
How to enter into the mdf function in the imported package
In your launch.json add the "justMyCode": false setting. That will allow you to step into third-party code.
"justMyCode": false github.com/microsoft/vscode-python/issues/…@Brett's answer is correct. However, when trying to debug 3rd party package while running unit tests (as opposed to running a predefined launch configuration) you need to create a separate configuration entry in the launch.json:
{
"name": "Debug Unit Test",
"type": "python",
"request": "test",
"justMyCode": false,
}
While debugging generaly you can step into to inspect the inner function/code.
@Tomasz's answer still works, though the editor would warn you that "test" is not an allowed value for the "request" property of launch configs configurations.
According to the discussion in https://github.com/microsoft/vscode-python/issues/15790 and the document in https://code.visualstudio.com/docs/python/testing#_debug-tests, I think now the recommended way to debug 3rd-party python package when running tests is:
{
"name": "Python: Debug Tests",
"type": "python",
"request": "launch",
"program": "${file}",
"purpose": ["debug-test"],
"console": "integratedTerminal",
"justMyCode": false
}
two lines should be set in project settings.
"justMyCode": false, "purpose":["debug-in-terminal"]
eg. launch.json:
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"purpose":["debug-in-terminal"],
"justMyCode": false,
"args": ["-arg1", "-arg1"],
"env": {"env1": "val1", "env2": "val2"}
}
]
A solution, from here:
{
"name": "Python: Debug Tests",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"purpose": ["debug-test"],
"console": "integratedTerminal",
"justMyCode": false
}