vscode-python: Debugger won't step over or into code

Environment data

  • VS Code version: 1.22.2
  • Extension version (available under the Extensions sidebar): 2018.4.0
  • OS and version: MacOS X High Sierra
  • Python version (& distribution if applicable, e.g. Anaconda): 3.6.5 homebrew installed
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): venv
  • Relevant/affected Python packages and their versions: pytest?

Actual behavior

When I set a breakpoint in a unit test, and run “debug test”, the debugger pauses correctly on the breakpoint, but I can’t step into or over using the buttons in the GUI. Whenever I press either button, the debugger next breaks at testlauncher.py on sys.exit().

The test does run to completion. Whilst at the breakpoint, the debugger works otherwise, e.g. I can see locals, use the console, etc.

Python and pytest are both set to the binaries in my venv. Linting (flake8) and running of individual tests are both working.

    "python.pythonPath": "/Users/maraspeli/Build/Python/jira-metrics/bin/python",
    "python.linting.enabled": true,
    "python.linting.flake8Enabled": true,
    "python.linting.flake8Path": "/Users/maraspeli/Build/Python/jira-metrics/bin/flake8",
    "python.unitTest.pyTestEnabled": true,
    "python.unitTest.pyTestPath": "/Users/maraspeli/Build/Python/jira-metrics/bin/pytest",

I get almost the same behaviour if I create and use a launch configuration like this instead of the built-in “debug test” launcher:

        {
            "name": "Python: Tests",
            "type": "python",
            "request": "launch",
            "pythonPath": "${config:python.pythonPath}",
            "program": "python",
            "module": "pytest",
            "args": [
                "-v",
            ],
            "debugOptions": [
                "RedirectOutput"
            ]
        }

The only difference here is that I don’t get paused again at sys.exit(), it just finishes the test run.

Expected behavior

Step over and step into steps through the lines in the file.

Steps to reproduce:

  1. Set breakpoint
  2. Debug a test
  3. Attempt to step over or into a function

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

(nothing relevant)

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

(nothing relevant)

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 18 (5 by maintainers)

Most upvoted comments

I get the same behavior even for regular python scripts, without any unit test package:

VS Code version: 1.27.1 Extension version (available under the Extensions sidebar): 2018.8.0 OS and version: Ubuntu 18.04 Python version (& distribution if applicable, e.g. Anaconda): 3.6.5 Type of virtual environment used (N/A | venv | virtualenv | conda | …): venv

One more data point: if I manually put another breakpoint (e.g. on line 7), the debuger does break there.

Basically, the best way to describe this behaviour is that both “step over (F10)” and “step into (F11)” are behaving like “continue (F5)”.