mfussenegger / nvim-dap-python

An extension for nvim-dap, providing default configurations for python and methods to debug individual test methods or classes.
GNU General Public License v3.0
571 stars 51 forks source link

Add support for passing args to runners #66

Closed holmanb closed 2 years ago

holmanb commented 2 years ago

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 commented 2 years ago

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>

mfussenegger commented 2 years ago

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
holmanb commented 2 years ago

Thanks for the consideration and response @mfussenegger.

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