nvim-neotest / neotest-python

MIT License
126 stars 38 forks source link

Options or command line for test runner #7

Closed wookayin closed 2 years ago

wookayin commented 2 years ago

My project is based on pytest, and I would like to use some custom options or command line flags for the pytest runner.

One particular example would be pytest --verbose --capture=no, so that I can see the standard output printed and captured during the test in the output view. I think this should be configurable via lua config or dynamically via run API (sometimes I would want to use just pytest or sometimes pytest -v, etc.). This feature would be not necessarily only for python but for all other languages/adapters in general.

wookayin commented 2 years ago

My desired pytest cmdline argument is pytest -vv -s. With the following config

adapters = {
  require("neotest-python")({
    dap = { justMyCode = false },
    args = { "-vv -s" },
    --runner = 'pytest',
  }),
  require("neotest-plenary"),
},

the output I get is:

ERROR: usage: neotest.py [options] [file_or_dir] [file_or_dir] [...]      
neotest.py: error: argument -v/--verbose: ignored explicit argument ' -s' 

When I try instead the following

    args = { "-s" },

the -s option seems to be applied on the pytest runner as expected. So maybe the above was just a corner case about dealing with the -v/--verbose option.

rcarriga commented 2 years ago

You need to separate the arguments args = { "-vv", "-s" },.

dynamically via run API

You can already do that with extra_args option

wookayin commented 2 years ago
args = { "-vv", "-s" }

Thanks, this works for pytest as intended. Appreciate answering a dumb question!