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.

Debugging test in VS Code does not work

See original GitHub issue

Environment data

Version: 1.43.1 (user setup) Commit: fe22a9645b44368865c0ba92e2fb881ff1afce94 Date: 2020-03-18T07:01:20.184Z Electron: 7.1.11 Chrome: 78.0.3904.130 Node.js: 12.8.1 V8: 7.8.279.23-electron.0 OS: Windows_NT x64 10.0.18363

  • Python version (& distribution if applicable, e.g. Anaconda): Python Anaconda 3.7.6 64-bit
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): Anaconda 1.9.12
  • Relevant/affected Python packages and their versions: Python 2020.3.69010
  • Relevant/affected Python-related VS Code extensions and their versions: Python 2020.3.69010

Expected behaviour

Debugging test should work.

Actual behaviour

Debugging test does not work. VS code shows error dialog. See in reproduction steps for more details. If I run the test without debugger the tests runs as expected.

Steps to reproduce:

Try to debug tests using unit test library, Click on the small bug icon for an individual test to debug. I get a dialog box error saying Invalid message: Duplicate entries in “env”. The two options i get are Open launch.json and Cancel.

I have checked my lauch.json and I do not have duplicate entries for any env variable.

Logs

ERR timeout after 500 ms: Error: timeout after 500 ms at t.RawDebugSession.handleErrorResponse (file:///C:/Users/AP/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:2954:952) at file:///C:/Users/AP/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:2954:250 at async t.RawDebugSession.shutdown (file:///C:/Users/AP/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:2952:336)

### Settings.json

{
    "python.testing.pytestArgs": [
        "tests"
    ],
    "python.testing.unittestEnabled": false,
    "python.testing.nosetestsEnabled": false,
    "python.testing.pytestEnabled": true
}

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:12
  • Comments:35 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
kimadelinecommented, Mar 24, 2020

@asipras Can you add the following configuration to your launch.json:

        {
            "name": "Python: Test debug config",
            "type": "python",
            "request": "test",
            "console": "integratedTerminal",
            "logToFile": true
        }

Try debugging your tests, and copy here the content of the debugpy*.log file from the extension folder.

@lorenzo-cavazzi are you getting the same Duplicate entries in "env" message? If that’s the case, there is something else going on in your setup that’s not related to the extension, because it’s a Windows-specific error message from the debugger:

https://github.com/microsoft/debugpy/blob/69db68a5f9aff6c1dfd955c8934c753212f94633/src/debugpy/launcher/handlers.py#L110-L119

3reactions
Varchalacommented, Apr 12, 2022

@robinstauntoncollins I can confirm this launch config is working.

Unfortunately then VS Code complains “test” isn’t a valid value for request. Valid values are “launch” or “attach”. Is there any solution/workaround for this?

I am facing the same issue.

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 >
Visual Studio Code (VS Code) Run Test button works fine but ...
VS Code works just fine when Run Test button (does not matter if via testing tab (left side) or by right click close...
Read more >
VS Code Debugger not working for python - Microsoft Q&A
I am experiencing debugging issue for my VS Code in WIN-10. ... It seems when I do Run->"start Debugging' no command comes to...
Read more >
How to Use VS Code to Debug Unit Test Cases | by Jennifer Fu
Click the following Run button on the left side panel. It presents an interface for Run and Debug. By specifying a proper configuration,...
Read more >
Using Visual Studio Code to debug Jest based unit tests
If you are working on a git repository, check your .gitIgnore file and make sure this .vscode folder is not ignored. Step 2...
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