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

pytest file opens on "assert" despite "JustMyCode" set to true. #58

Open
chaudry-786 opened this issue Nov 20, 2023 · 2 comments
Open

Comments

@chaudry-786
Copy link

Hello, my config is bare minimum and I only want my code debugged.

keymap("n", "<Leader>dt", ":lua require('neotest').run.run({strategy = 'dap'})<CR>", opts)
require("neotest").setup({
    adapters = {
        require("neotest-python")({
            dap = { justMyCode = true },
            python = venv_dir .. "python",
            runner = "pytest",
        })
    }
})

Take this test for example:

def test_addition():
    dic = {"name": "cat"}
    json.dumps(dic)
    assert 2 + 3 == 5

When I go past the line with "assert", then file "~/.local/share/nvim/lazy/neotest-python/neotest_python/pytest.py" and function "pytest_runtest_makereport" opens. I just want to debug my code. Interestingly if I try to "step in" at "json.dumps(dic)", I correctly get this message:

Note: may have been skipped because of "justMyCode" option (default == true).
@wookayin
Copy link
Contributor

When I go past the line with "assert"

by doing this you get out of "my code". After this line where error is thrown out of your code, it is catched by the pytest framework.

{ justMyCode = true },

you want DAP to handle your code only.

So they conflict by definition?

@istrupin
Copy link

When I go past the line with "assert"

by doing this you get out of "my code". After this line where error is thrown out of your code, it is catched by the pytest framework.

{ justMyCode = true },

you want DAP to handle your code only.

So they conflict by definition?

I am inclined to agree with @chaudry-786 here in that the behavior was unexpected for me too. If justMyCode is set to true, I would expect the debugger to not put me into pytest, since pytest is library code, not my code. I'd expect to just have the behavior of the test passing or failing with the Note: may have been skipped because of "justMyCode" option (default == true). message displayed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants