question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Read test debug configuration from settings not just launch.json

See original GitHub issue

Issue Type: Bug

Behaviour

Expected vs. Actual

Adding this to my .vscode/launch.json allows me to use breakpoints in third-party libraries when debbuging unit tests:

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

I expect that adding the same to the launch section of my workspace settings would produce the same behaviour but this is not true.

Steps to reproduce:

  1. Add the above debug config to your .vscode/launch.json file.
  2. Add a breakpoint to a third party tool.
  3. Debug a unit test that calls the third party code and the debbuger will stop in the breakpoint.
  4. Delete the .vscode/launch.json file.
  5. Add the above debug config in your workspace settings.
  6. Add a breakpoint to a third party tool.
  7. Debug a unit test that calls the third party code and the debbuger will skip the breakpoint.

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.10.0
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
  • Value of the python.languageServer setting: Default
User Settings


defaultLS: {"defaultLSType":"Pylance"}

downloadLanguageServer: true

envFile: "<placeholder>"

venvPath: "<placeholder>"

venvFolders: "<placeholder>"

condaPath: "<placeholder>"

pipenvPath: "<placeholder>"

poetryPath: "<placeholder>"

languageServer: "Pylance"

linting
• enabled: true
• cwd: "<placeholder>"
• Flake8Args: "<placeholder>"
• flake8Enabled: true
• flake8Path: "<placeholder>"
• lintOnSave: true
• banditArgs: "<placeholder>"
• banditEnabled: false
• banditPath: "<placeholder>"
• mypyArgs: "<placeholder>"
• mypyEnabled: true
• mypyPath: "<placeholder>"
• pycodestyleArgs: "<placeholder>"
• pycodestyleEnabled: false
• pycodestylePath: "<placeholder>"
• prospectorArgs: "<placeholder>"
• prospectorEnabled: false
• prospectorPath: "<placeholder>"
• pydocstyleArgs: "<placeholder>"
• pydocstyleEnabled: false
• pydocstylePath: "<placeholder>"
• pylamaArgs: "<placeholder>"
• pylamaEnabled: false
• pylamaPath: "<placeholder>"
• pylintArgs: "<placeholder>"
• pylintPath: "<placeholder>"

sortImports
• args: "<placeholder>"
• path: "<placeholder>"

formatting
• autopep8Args: "<placeholder>"
• autopep8Path: "<placeholder>"
• provider: "autopep8"
• blackArgs: "<placeholder>"
• blackPath: "<placeholder>"
• yapfArgs: "<placeholder>"
• yapfPath: "<placeholder>"

testing
• cwd: "<placeholder>"
• debugPort: 3000
• nosetestArgs: "<placeholder>"
• nosetestsEnabled: undefined
• nosetestPath: "<placeholder>"
• promptToConfigure: true
• pytestArgs: "<placeholder>"
• pytestEnabled: true
• pytestPath: "<placeholder>"
• unittestArgs: "<placeholder>"
• unittestEnabled: false
• autoTestDiscoverOnSaveEnabled: true

terminal
• activateEnvironment: true
• executeInFileDir: "<placeholder>"
• launchArgs: "<placeholder>"

experiments
• enabled: true
• optInto: []
• optOutFrom: []

insidersChannel: "off"

tensorBoard
• logDirectory: "<placeholder>"

Extension version: 2022.2.1924087327 VS Code version: Code 1.65.2 (c722ca6c7eed3d7987c0d5c3df5c45f6b15e77d1, 2022-03-10T15:36:26.048Z) OS version: Linux x64 4.14.240 Restricted Mode: No

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:3
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
MetRonniecommented, Apr 25, 2022

It doesn’t help that the command Open 'launch.json' in the command palette just opens settings.json if you haven’t got a launch.json. That makes you think there would be no difference between where you add a configuration

1reaction
luabudcommented, Mar 25, 2022

Hi @ElPincheTopo, the launch.json configuration has changed for debugging tests (see https://code.visualstudio.com/docs/python/testing#_debug-tests). Can you try the configuration below?

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

And just out of pure curiosity, what is the reason behind using it on your workspace configuration rather than launch.json?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Debugging in Visual Studio Code
To run or debug a simple app in VS Code, select Run and Debug on the Debug start view or press F5 and...
Read more >
The launch.json file for the DevTools extension - Microsoft Learn
In the Run and Debug Side Bar, click Start Debugging. The two DevTools tabs open, and Visual Studio Code enters Debug mode. This...
Read more >
How to disable "just my code" setting in VSCode debugger?
Just adding "justMyCode": false to launch.json doesn't work. You need to add a separate config in launch.json like below.
Read more >
Debugging
To get started debugging, run the command Debug: Open launch.json . If you did not already have a launch.json file for your project,...
Read more >
Troubleshooting - Jest
When Jest executes the test that contains the debugger statement, ... Then attach VS Code's debugger using the following launch.json config:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found