nvim-neotest / neotest-python

MIT License
115 stars 34 forks source link

Add support for conditional arguments per strategy #57

Closed vashcheulov closed 8 months ago

vashcheulov commented 9 months ago

This PR adds support for conditional arguments per strategy.

This change is necessary in order to add extra arguments or modify them depending on selected strategy. E.g. when project is using pytest-cov and dap strategy is used when running tests, then debugpy is not stopping at breakpoints (see pytest-cov limitiation). PR allows to compare selected strategy in args function to disable coverage when debugging:

require("neotest").setup({
  adapters = {
    require("neotest-python")({
      args = function(runner, position, strategy)
        local args = {}
        if strategy == "dap" and runner == "pytest" then
          args = vim.list_extend(args, { "--no-cov" })
        end
        return args
      end,
    }),
  },
})
rcarriga commented 8 months ago

LGTM thanks for the PR! :smile: