
Testing integrated in neovim with pytest. Include Docker support. This project is in progress, I will be adding more features in the future and I open to contributions.
These instructions will help you set up and use pytest.nvim in your Neovim environment.
- Neovim 0.5.0 or later
- pytest in your environment (pip install pytest)
-
Install the pytest.nvim plugin using your preferred plugin manager:
Lazyvim:
{ "richardhapb/pytest.nvim", opts = {} }Packer:
use { "richardhapb/pytest.nvim", opt = true }Vim-Plug:
Plug 'richardhapb/pytest.nvim'
-
Load the pytest plugin in your Neovim configuration if you haven't already done so. For example:
require('pytest').setup() -
Use the :Pytest command to run the tests in the current buffer.
-
To check the entire buffer:
-
To check the output of the tests:
-
You can attach the test to the current buffer, this runs test on save:
-
You can detach the test from the current buffer:
-
Docker enable on the way
-
Docker disabled on the way
-
The default keybinding that runs :Pytest is <leader>T.
The plugin provides the following default keymap:
- <leader>TT - Run pytest for the current file (normal mode)
- <leader>Ta - Attach pytest to the current buffer (normal mode)
- <leader>Td - Detach pytest from the current buffer (normal mode)
Default settings, is not necessary to set up, but you can change the settings in your configuration file.
Options can be callbacks, for example: