Skip to content

How to make sure debugpy is used for debugging tests? #112

Closed

Description

Brett Cannon (@brettcannon) said in microsoft/vscode-python#21748 (comment) that pressing the “debug test” button in the Python extension’s test view should use this extension if available.

I tried to set the justMyCode setting to true without a launch configuration to check it out. My breakpoint in library code wasn’t respected. That makes me think that either the Python extension used its own debugger or the justMyCode setting doesn’t work reliably.

Is there a way to configure or even see which debugger extension provides the functionality to see which one it is?

Activity

  1. blakeNaccarato commented on Nov 17, 2023

    @blakeNaccarato

    I have found a workaround for now, shown in .vscode/launch.json below, as seen in referenced commit from my project template.

    Also, here's some possibly useful information for debugging this issue. When I introduce the pytest debug configuration below, of type python (as opposed to debugpy), with purpose debug-test and justMyCode disabled, I can debug inside of third-party code when running test suites through the test adapter (I'm using the preview test adapter).

    If I don't have that pytest debug configuration present, or configured exactly as described above, I can't step into third-party code then running via test adapter. I've also tried setting debug-test purpose in the Python: Current file adapter (driven by debugpy), explicitly toggling justMyCode in that, using the debugpy.debugJustMyCode setting, and combinations of all that.

    I haven't tried all of that over again while explicitly opting out of the new test adapter, however.

    Workaround: .vscode/launch.json

    {
      "version": "0.2.0",
      "configurations": [
        {
          "name": "Python: Current file",
          "type": "debugpy",
          "request": "launch",
          "program": "${file}",
          "console": "internalConsole"
        },
        ...
        {
          "name": "pytest",
          "purpose": ["debug-test"],
          "presentation": {
            "hidden": true
          },
          "type": "python",
          "request": "launch",
          "program": "${file}",
          "console": "internalConsole",
          "justMyCode": false
        }
      ]
    }
  2. eleanorjboyd commented on Nov 27, 2023

    @eleanorjboyd
    Member

    Paula (@paulacamargo25), do you have any thoughts on this and if the workaround is required?

  3. blakeNaccarato commented on Nov 28, 2023

    @blakeNaccarato

    I know it's just my machine, but I tried again with the latest extension version: debugging tests specifically setting the debugpy adapter with the debug-test purpose again, and with the workaround removed altogether (debugpy.debugJustMyCode set to false). It looks like for my machine that the described workaround is still required. Below are system version details from when I tried this again today. Let me know if it would help to try this with minimal extensions enabled or with extension bisect or something like that, or whether you are able to repro on your end. Thanks!

    Python Debugger extension version: v2023.3.13271006
    Version: 1.84.2 (user setup)
    Commit: 1a5daa3a0231a0fbba4f14db7ec463cf99d7768e
    Date: 2023-11-09T10:51:52.184Z
    Electron: 25.9.2
    ElectronBuildId: 24603566
    Chromium: 114.0.5735.289
    Node.js: 18.15.0
    V8: 11.4.183.29-electron.0
    OS: Windows_NT x64 10.0.19045
    
  4. bersbersbers commented on Dec 10, 2023

    @bersbersbers
    Contributor

    I know it's just my machine

    It's not, I have the same issue. Your workaround helps a lot. Happy to help investigate/debug this if anyone has specific instructions.

  5. added
    feature-requestRequest for new features or functionality
    and removed
    triage-neededNeeds assignment to the proper sub-team
    on Jan 25, 2024
  6. paulacamargo25 commented on Jan 29, 2024

    @paulacamargo25
    Contributor

    Since testing is handled on the python extension side, a change needs to be made to start using the python debugger extension.

  7. paulacamargo25 commented on Feb 14, 2024

    @paulacamargo25
    Contributor

    This issue was already solved in insiders, could you try testing again with the last pre-release version on the python extension?

  8. paulacamargo25 commented on Feb 15, 2024

    @paulacamargo25
    Contributor

    closed in : #174

  9. added
    bugIssue identified by VS Code Team member as probable bug
    and removed
    feature-requestRequest for new features or functionality
    on Feb 15, 2024
  10. andreamah commented on Feb 22, 2024

    @andreamah

    Paula (@paulacamargo25) do you have verification steps for this?

  11. bersbersbers commented on Feb 29, 2024

    @bersbersbers
    Contributor

    This is working for me in Python Debugger v2024.2.0. Thanks!

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

Metadata

Metadata

Labels

*duplicateIssue identified as a duplicate of another issue(s)bugIssue identified by VS Code Team member as probable bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions