Skip to content

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

Closed
microsoft/vscode-python
#23814

Description

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:

  • ❌ 1-debugpy-adapter-settings-justmycode
    • Here we omit justMyCode in launch.json.
    • We specify debug-test in our purpose.
    • We do explicitly disable the global setting debugpy.debugJustMyCode in settings.json.
    • We cannot stop at breakpoints in standard library code here.
  • ✅ 2-debugpy-adapter: Here we explicitly disable justMyCode in launch.json and specify debug-test in our purpose. We successfully stop at breakpoints in standard library code here.
  • ✅ 3-vscode-python-debug-adapter: Here we use the soon-to-be-deprecated python debug adapter, explicitly disable justMyCode in launch.json, and specify debug-test in our purpose. We successfully stop at breakpoints in standard library code here.

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

Activity

  1. added
    feature-requestRequest for new features or functionality
    and removed
    triage-neededNeeds assignment to the proper sub-team
    on May 30, 2024
  2. rzhao271 commented on Jul 23, 2024

    @rzhao271
    Contributor

    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.

  3. 4 remaining items

  4. paulacamargo25 commented on Jul 25, 2024

    @paulacamargo25
    Contributor

    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.
  5. rzhao271 commented on Jul 25, 2024

    @rzhao271
    Contributor

    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.

  6. brettcannon commented on Jul 25, 2024

    @brettcannon
    Member

    Brett Cannon (@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.

  7. mapa17 commented on Dec 13, 2024

    @mapa17

    Hi,

    I am running vscode

    Version: 1.96.0
    Commit: 138f619c86f1199955d53b4166bef66ef252935c
    Date: 2024-12-11T02:29:09.626Z
    Electron: 32.2.6
    ElectronBuildId: 10629634
    Chromium: 128.0.6613.186
    Node.js: 20.18.1
    V8: 12.8.374.38-electron.0
    OS: Linux x64 6.9.7-arch1-1
    

    and fail to step any 3rd party (library code) through the test debugging. I have used the repository and code provided by Blake Naccarato (@blakeNaccarato) but none of the versions (neither 2 or 3 that should work) give me an option to debug the simple test code

    import json
    
    def test_answer():
        assert json.dumps({'toto': 'tata'}) == "{'toto': 'tata'}"

    I am able to step into the code using the "normal" debugging functionality.

  8. eleanorjboyd commented on Dec 13, 2024

    @eleanorjboyd
    Member

    Hi Pasieka Manuel (@mapa17), I gave these a try with debugging the test and 2 and 3 work (1 is not working for me right now which I need to investigate). Can you outline how exactly you ran 2 and 3 that caused them to not work? Did you use pytest? Can you include a video or gif? Did you add any other settings?

  9. mapa17 commented on Dec 14, 2024

    @mapa17

    Hello, thank you for investigating. I have in my .venv

    iniconfig 2.0.0
    packaging 24.2
    pip       24.0
    pluggy    1.5.0
    pytest    8.3.4
    

    and the whole test project consist of

    (.venv) [mapa17@Bucephalus test]$ cat .vscode/settings.json 
    {
        "workbench.colorCustomizations": {
            "activityBar.background": "#2A2367",
            "titleBar.activeBackground": "#3B3190",
            "titleBar.activeForeground": "#FAFAFD"
        },
        "python.testing.pytestEnabled": true
    }
    
    (.venv) [mapa17@Bucephalus test]$ cat .vscode/launch.json 
    {
        "version": "0.2.0",
        "configurations": [
          {
            "name": "Python Debugger: Current File",
            "type": "debugpy",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "purpose": ["debug-test", "debug-in-terminal"],
            "justMyCode": false
          }
        ]
      }
    
    (.venv) [mapa17@Bucephalus test]$ cat tests/test_json.py 
    import json
    
    def test_answer():    
        assert json.dumps({'toto': 'tata'}) == '{"toto": "tata"}'

    When I start debugging (F5) of the test file, i can step into the json.dumps code. When I use the Testing menu and start debugging there, the dumps() is stepped over.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature-requestRequest for new features or functionalitytriage-neededNeeds assignment to the proper sub-teamverification-neededVerification of issue is requestedverifiedVerification succeeded

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions