enc: add python unit test config

This commit is contained in:
asep.komarudin 2024-06-18 15:02:23 +07:00
parent 68cf0d9468
commit bb58e61e35
3 changed files with 56 additions and 13 deletions

View file

@ -136,20 +136,15 @@ pcode.columnline = true
pcode.telescope_theme_find_file = "center"
pcode.telescope_theme_live_grep = "dropdown"
-- https://github.com/ThePrimeagen/refactoring.nvim
pcode.refactoring = false
-- https://github.com/kristijanhusak/vim-dadbod-ui
pcode.database = false
-- https://github.com/nvim-neotest/neotest-jest
pcode.jest = false
pcode.jest_command = "npm test -- "
pcode.jest_config = "jest.config.mjs"
-- https://github.com/rest-nvim/rest.nvim
pcode.rest_client = true
-- https://github.com/ThePrimeagen/refactoring.nvim
pcode.refactoring = false
-- https://github.com/mfussenegger/nvim-dap
pcode.nvim_dap = false -- not support for windows os (auto config mason-nvim-dap)
pcode.nvim_dap_javascript = false
@ -158,3 +153,10 @@ pcode.nvim_dap_python = false
-- https://github.com/olimorris/neotest-phpunit
pcode.phpunit = false
-- https://github.com/nvim-neotest/neotest-python
-- https://docs.pytest.org/en/7.1.x/getting-started.html
pcode.pytest = true
-- https://github.com/nvim-neotest/neotest-jest
pcode.jest = false
pcode.jest_command = "npm test -- "
pcode.jest_config = "jest.config.mjs"

42
lua/plugins/test_py.lua Normal file
View file

@ -0,0 +1,42 @@
local M = {}
if pcode.pytest then
M = {
"nvim-neotest/neotest",
dependencies = {
"mfussenegger/nvim-dap-python",
"antoinemadec/FixCursorHold.nvim",
"nvim-neotest/nvim-nio",
"nvim-neotest/neotest-python",
},
config = function()
local mason_path = vim.fn.glob(vim.fn.stdpath("data") .. "/mason/")
pcall(function()
require("dap-python").setup(mason_path .. "packages/debugpy/venv/bin/python")
end)
require("neotest").setup({
adapters = {
require("neotest-python")({
dap = { justMyCode = false },
args = { "--log-level", "DEBUG" },
runner = "pytest",
python = "python",
}),
},
})
end,
-- stylua: ignore
keys = {
{ "<leader>T","",desc="  Test"},
{ "<leader>Tt", function() require("neotest").run.run(vim.fn.expand("%")) end, desc = "Run File" },
{ "<leader>Tr", function() require("neotest").run.run() end, desc = "Run Nearest" },
{ "<leader>TT", function() require("neotest").run.run(vim.loop.cwd()) end, desc = "Run All Test Files" },
{ "<leader>Tl", function() require("neotest").run.run_last() end, desc = "Run Last" },
{ "<Leader>Ts", function() require("neotest").summary.toggle() end, desc = "Toggle Summary" },
{ "<leader>To", function() require("neotest").output.open({ enter = true, auto_close = true }) end, desc = "Show Output" },
{ "<Leader>TO", function() require("neotest").output_panel.toggle() end, desc = "Toggle Output Panel" },
{ "<Leader>TS", function() require("neotest").run.stop() end, desc = "Stop" },
},
}
end
return M