0

I have installed vim-test, and setup the following pytest executable in my .vimrc:

let g:test#python#pytest#executable = 'python3 -m pytest'

When I call :TestFile, pytest runs in a background shell and display errors. But I would like to display those errors with file names and line numbers in a quick fix window that can be used to jump to the file at that line number.

The vim test readme mentions several quickfix-strategies:

https://github.com/vim-test/vim-test#quickfix-strategies

Is there a way to simply display the errors in a quickfix window, without creating a makefile?

4
  • I added let test#strategy = "dispatch" to .vimrc so that the test output appears in a vim split (using tpope/vim-dispatch). But it still doesn't provide the link to jump to line numbers within files. Commented Jul 4, 2023 at 9:18
  • Have you tried 'make' strategy?
    – romainl
    Commented Jul 4, 2023 at 9:31
  • Thanks let test#strategy = "make" does create a link to the particular line in the file, but the split disappears when pressing enter on that file & line number. I am used to a quick fix window, for example when calling ":Git grep", files and line numbers are display and remain after clicking on them. Commented Jul 4, 2023 at 9:56
  • 1
    You might try :copen after one of those strategies. There are also a few commands (cbuffer?) that can create a quickfix list from arbitrary buffers/files/expressions
    – D. Ben Knoble
    Commented Jul 4, 2023 at 16:11

1 Answer 1

1

In .vimrc, define strategies to send the test output

let test#strategy = "make"
" or
" let test#strategy = "dispatch"

After running vim test's :TestFile or :TestSuite on a pytest script, use :copen to display the test result in a quickfix window. Lines of the errors that contain a file name and a line number will create a link that directly sends you to the file and line where the error occurred.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.