A Neovim plugin that integrates with Python's approvaltests library. Run pytest from within Neovim and review approval mismatches in a side-by-side diff popup.
- Async pytest execution (non-blocking)
- Side-by-side diff floating windows with scroll sync
- Approve or reject changes with a single keypress
- Navigate through multiple failures
- Auto-detects approval mismatches from pytest output
Using lazy.nvim:
{
"alimasry/pytest-approve.nvim",
config = function()
require("approval").setup()
end,
ft = "python",
}The plugin automatically suppresses external diff tools (e.g. VS Code) by injecting a ReportQuietly reporter via a bundled pytest plugin. No conftest.py needed.
To disable this and manage the reporter yourself, set inject_reporter_plugin = false in your setup:
require("approval").setup({
inject_reporter_plugin = false,
})| Key | Action |
|---|---|
<leader>tn |
Run nearest test |
<leader>tf |
Run all tests in file |
]a / [a |
Next / previous failure |
Inside the diff popup:
| Key | Action |
|---|---|
a |
Approve (rename .received.txt to .approved.txt) |
q |
Reject / close |
]a / [a |
Next / previous failure |
:ApprovalRunNearest— Run the test nearest to cursor:ApprovalRunFile— Run all tests in the current file:ApprovalApprove— Approve the current failure:ApprovalReject— Reject the current failure
require("approval").setup({
pytest_cmd = "pytest", -- pytest executable
pytest_args = { "-v", "--tb=short" }, -- default pytest arguments
inject_reporter_plugin = true, -- auto-suppress external diff tools
keymaps = {
run_nearest = "<leader>tn",
run_file = "<leader>tf",
next_failure = "]a",
prev_failure = "[a",
},
})- Open a Python test file that uses
approvaltests.verify() - Press
<leader>tnto run the nearest test - If no
.approved.txtexists, the diff popup shows an empty left pane vs the received output - Press
ato approve — the.received.txtis renamed to.approved.txt - Run the test again — it passes with a success notification
- If the output changes, the popup shows the diff between the old approved and new received content
- Press
qto reject and keep the.approved.txtunchanged
- Neovim >= 0.9
- Python with approvaltests installed
- pytest