Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python test debugging is not working #11427

Closed
nandemoi opened this issue Apr 27, 2020 · 6 comments
Closed

Python test debugging is not working #11427

nandemoi opened this issue Apr 27, 2020 · 6 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug

Comments

@nandemoi
Copy link

nandemoi commented Apr 27, 2020

Environment data

  • VS Code version: 1.44.2
  • Extension version (available under the Extensions sidebar): 2020.4.74986
  • OS and version: macOS 10.15.4
  • Python version (& distribution if applicable, e.g. Anaconda): 3.8.2
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A

Expected behaviour

starting debugging

Actual behaviour

as #7927, the debugging tool bar disappeared

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

same as #7927

@nandemoi nandemoi added triage-needed Needs assignment to the proper sub-team bug Issue identified by VS Code Team member as probable bug labels Apr 27, 2020
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Apr 27, 2020
@int19h
Copy link

int19h commented Apr 27, 2020

Can you please provide more information about the issue? In particular, the repro steps - including your launch.json, and, if possible the code that you're trying to debug.

Also, please make sure that you're running debugpy.

@jakebrinkmann
Copy link

jakebrinkmann commented Apr 27, 2020

I am not using a launch.json, just the built in test runner. python.testing.pytestEnabled

@int19h I installed debugpy from vsix (your link) to no avail. No breakpoints or exceptions are being caught when I click debug, even though debug text is displayed in the debug console

@jakebrinkmann
Copy link

@int19h I created a launch file:

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Python: Module",
      "type": "python",
      "request": "launch",
      "module": "pytest"
    }
  ]
}

My assert 1 < 0 was not caught:

# test_this.py
def test_():
    assert 1 < 0 

@int19h int19h changed the title reopen Python debugging not working #7927 for Python 3.8 Python test debugging is not working Apr 27, 2020
@int19h
Copy link

int19h commented Apr 27, 2020

If you're running the code using "Debug Test" in the editor or in Test Explorer, the configuration needs to be "request": "test" to apply, and you don't need "module": "pytest" (it will take care of running the correct module etc).

It doesn't look like that's important here, though - I was just wondering if there's anything unusual in the config. Running without one should work.

Where is test_this.py located? The most common reason why breakpoints aren't being hit is because "justMyCode" setting is enabled in debug configuration (it's on by default), and the source file is in a location that debugger considers as Python stdlib - e.g. anywhere inside the folder where Python is installed, or inside a virtual environment.

@jakebrinkmann
Copy link

@int19h this seems to be the error, settings.json:

{
  "python.testing.pytestArgs": [
    "--cov", "./src",
    "--color=yes"
  ],
}

Those arguments together are causing the debugger to not raise breakpoints or catch exceptions.

@int19h
Copy link

int19h commented Apr 27, 2020

Ohh, --cov is code coverage, isn't it? It's not compatible with debuggers in general. The usual approach is to have two different configurations, with and without coverage.

@int19h int19h closed this as completed Apr 27, 2020
@ghost ghost removed the triage label Apr 27, 2020
@lock lock bot locked as resolved and limited conversation to collaborators May 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

4 participants