microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.29k stars 1.17k forks source link

Debugging test in VS Code does not work #10722

Open asipras opened 4 years ago

asipras commented 4 years ago

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

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
}
lhotamir commented 1 year ago

@eleanorjboyd Still not working for me :( I enabled the experimental pythonTestAdapter but I still get the duplicate PATH in env error. I did not make any other changes to my config and when I start VS Code by shortcut (not code command in git bash) debugging still works.

Python extension v2023.12.0

eleanorjboyd commented 1 year ago

@lhotamir, thank you for trying it and seeing if it works. Sorry the issue still exists and I will look to address it soon since that will be easier with the rewrite. Thanks

plaa commented 1 year ago

I just hit the same problem, running tests works fine but debugging a test fails with ModuleNotFoundError: No module named 'my_main_module'

I tested older versions and v2023.8.0 and older work:

v2023.14.0 Debugging tests fail ❌ v2023.12.0 Debugging tests fail ❌ v2023.10.1 Unittest discovery fails with ModuleNotFoundError: No module named 'my_main_module' ❌ v2023.10.0 Unittest discovery fails with ModuleNotFoundError: No module named 'my_main_module' ❌ v2023.8.0 (and older) work as expected ✅

karrtikr commented 1 year ago

Activation issues related to debugging tests were recently fixed, try using the latest version of VS Code and Python extension. cc/ @plaa

eleanorjboyd commented 10 months ago

Hello! I have reviewed this issue and given the architectural changes of the testing rewrite, this issue should no longer exist on the rewrite. Therefore I am going to close this issue but please comment or open a new issue if you are still seeing a problem when you try this yourself!

To use the rewrite yourself just add ”python.experiments.optInto": ["pythonTestAdapter"] to your user settings. You can confirm you have the rewrite enabled by setting your log level to trace, via the Developer: Set Log Level command in the command palette. Then check to see if Experiment 'pythonTestAdapter' is active is in your python logs.

Thanks!

immanuelazn commented 9 months ago

Hi, I've noticed a separate issue when interfacing with Azure credentials now.

Debugging appears to work, however it appears that the behavior is now different than how a traditional "run" in a test would work. In my case, DefaultAzureCredentials() does not function correctly and throws an error, but works in run mode within the tests window. I have also used with and without ”python.experiments.optInto": ["pythonTestAdapter"], confirmed with the new test adapter. The following versions have been tested

eleanorjboyd commented 9 months ago

hello @immanuelazn, would you be able to create a new issue with the information so we can triage it and better understand the issue? Thanks!

schwaerz commented 8 months ago

To me this issue does not seem to be fixed. I am currently running v2023.22.1 of the plugin together with behave.

Error message is exaclty the same one as reported initially.

When I downgrade to 2023.8.0 it will work again.

The following did not help:

"python.experiments.optInto": ["pythonTestAdapter"]
eleanorjboyd commented 7 months ago

@schwaerz are you still experiencing this issue? Could you describe your project structure and include your logs so we can take a closer look? Thanks