microsoft / vscode-python-debugger

Python debugger (debugpy) extension for VS Code.
https://marketplace.visualstudio.com/items?itemName=ms-python.debugpy
MIT License
57 stars 24 forks source link

Disabling `debugpy.debugJustMyCode` in `settings.json` doesn't apply to the `debug-test` `purpose` in `launch.json` #335

Closed blakeNaccarato closed 2 months ago

blakeNaccarato commented 5 months ago

I'm using "Python Debugger" extension v2024.6.0. It looks like microsoft/vscode-python#22903 closed related issues #174 and #112, but this is not exactly the same issue. Basically, disabling debugpy.debugJustMyCode in settings.json doesn't apply to the debug-test purpose in launch.json. See https://github.com/blakeNaccarato/vscode-python-debugger-335 for a minimal repro of three behaviors. The subfolders represent three different debug configurations:

Could debugpy.debugJustMyCode global toggle in settings.json be extended to cover test debugging as well?

It's nice to have a global toggle for this, so that a launch.json config checked into the repo doesn't have a merge-conflict-prone justMyCode toggle embedded in it.

Here's the output of my VSCode Help > About:

Version: 1.88.1 (user setup)
Commit: e170252f762678dec6ca2cc69aba1570769a5d39
Date: 2024-04-10T17:41:02.734Z
Electron: 28.2.8
ElectronBuildId: 27744544
Chromium: 120.0.6099.291
Node.js: 18.18.2
V8: 12.0.267.19-electron.0
OS: Windows_NT x64 10.0.22631
rzhao271 commented 2 months ago

Python Debugger: v2024.9.2024072301 (pre-release) Python: v2024.11.2024072302 (pre-release)

Case 1 is still failing for me above. When I set a breakpoint for json.dumps in .conda\Lib\json\__init__.py and run the "Python Debugger: Current File" launch config on test_sample.py, the debugger does not stop at the breakpoint.

blakeNaccarato commented 2 months ago

I can confirm that Case 1 is still failing for me as well, with the same setup as my original post, but with v2024.9.12041011 (pre-release) of the Python Debugger extension. I've added a VSCode workspace file to my minimal repro repo that demonstrates the cases side-by-side, with cases two and three working, but case one still not working.

I'm using vanilla virtual environments via Python's venv module, though I see conda's also showing the issue. Also there was a test discovery regression in pytest==8.3.1 affecting conda that's already fixed but not in a new release, so be aware of that when working on this issue.

andreamah commented 2 months ago

@brettcannon did you close this because the issue has been resolved? Otherwise, we would want to keep it open.

paulacamargo25 commented 2 months ago

Can someone test again? i am adding verification steps.

Verification Steps:

  1. Create a simple unittest in python that uses an external library.
  2. Add a breakpoint in the function call.
  3. Update debugpy.debugJustMyCode to true
  4. Try to step into the external library.
rzhao271 commented 2 months ago

Re-verified and LGTM.

It looks like running the launch config on sample.py works, and that running the launch config on test_sample.py works after explicitly adding a call to the test_answer() test function. I'm unsure whether the launch config could directly run a test for you.

brettcannon commented 2 months ago

@brettcannon did you close this because the issue has been resolved? Otherwise, we would want to keep it open.

It closed because GitHub thought my syncing of the main branch on my fork meant it should re-apply all of the "Closes" comments.