Giter Site home page Giter Site logo

Comments (5)

mfussenegger avatar mfussenegger commented on May 31, 2024 3

Looks like this is a pytest-cov / debugpy limitation. See microsoft/debugpy#863 (comment)

from nvim-dap-python.

jeanlucthumm avatar jeanlucthumm commented on May 31, 2024

The debugger works when I'm inside a non-test, main() function, set a breakpoint, and do lua require'dap'.continue(), so maybe there's something wrong with pytest setups specifically?

from nvim-dap-python.

philkoch avatar philkoch commented on May 31, 2024

I'm having a similar issue. Configured nvim-dap-python with examples from the docs

local mason_path = vim.fn.glob(vim.fn.stdpath "data" .. "/mason/")
require("dap-python").setup(mason_path .. "packages/debugpy/venv/bin/python")
require("dap-python").test_runner = "pytest"
-- mappings
lvim.builtin.which_key.mappings["dm"] = { "<cmd>lua require('dap-python').test_method()<cr>", "Test Method" }
lvim.builtin.which_key.mappings["df"] = { "<cmd>lua require('dap-python').test_class()<cr>", "Test Class" }

When invoking the test_method-action in a pytest-unittest file, the debugger starts as expected, but does not stop at breakpoints. Same as for the others, the debugger and breakpoints work fine when used in "normal" python modules.

from nvim-dap-python.

mfussenegger avatar mfussenegger commented on May 31, 2024

A minimal example with reproduction steps would be good.

Using a simple:

def inc(x):
    return x + 1

def test_answer():
    assert inc(3) == 5

And running :lua require('dap-python').test_method() with the cursor in test_answer, test_runner set to pytest, and a breakpoint in the inc body works fine for me.

from nvim-dap-python.

philkoch avatar philkoch commented on May 31, 2024

Sorry for the late reply, I didn't find time to test it earlier.
I found out what broke it for me. I'm using a poetry environment in which all dev-tools are configured via the pyproject.toml. PyTest is also configured in there:

[tool.pytest.ini_options]
addopts = "--cov" # <-- no stopping at breakpoints with --cov
testpaths = ["tests"]

When the --cov is added nvim-dap-python does not stop at breakpoints, when I remove it it works fine.

from nvim-dap-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.