nvim-dap-python icon indicating copy to clipboard operation
nvim-dap-python copied to clipboard

Add support for passing args to runners

Open holmanb opened this issue 3 years ago • 2 comments

This allows users to customize runner commands with a table of args to add to the test runner call.

from my config:

" DAP - debug adapter protocol                                                  
lua require("dap-python").setup("~/.virtualenvs/debugpy/bin/python")            
lua require("dap-python").test_runner = 'pytest'                                
lua require("dap-python").args = {'-v'}        

In this example it prints assertion failures more verbosely (tested locally).

(fair warning - I don't know lua, but it works so figured I'd offer a PR)

holmanb avatar Sep 16 '22 02:09 holmanb

This will also come in very handy for a future possible https://github.com/mfussenegger/nvim-dap-python/issues/63 implementation, which is often executed via tox -e <environment>

holmanb avatar Sep 16 '22 02:09 holmanb

Thanks for the PR.

I'm not sure how I feel about the interface. It's global and would apply to all runners, and it's also not clear that it only applies to runners and not other launch configurations.

It would already be possible to do something like this by adding a custom runner function:

local pytest = M.test_runners.pytest
require('dap-python').test_runners.pytest = function(...)
  local module, args = pytest(...)
  table.insert(args, '-v')
  return module, args
end

mfussenegger avatar Oct 08 '22 17:10 mfussenegger

Thanks for the consideration and response @mfussenegger.

I'll close this PR in favor of existing functionality.

holmanb avatar Oct 16 '22 19:10 holmanb