feat: remove plenary
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
local nio = require("nio")
|
local nio = require("nio")
|
||||||
local lib = require("neotest.lib")
|
local lib = require("neotest.lib")
|
||||||
local Path = require("plenary.path")
|
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
@@ -8,7 +7,7 @@ function M.is_test_file(file_path)
|
|||||||
if not vim.endswith(file_path, ".py") then
|
if not vim.endswith(file_path, ".py") then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
local elems = vim.split(file_path, Path.path.sep)
|
local elems = vim.split(file_path, lib.files.sep)
|
||||||
local file_name = elems[#elems]
|
local file_name = elems[#elems]
|
||||||
return vim.startswith(file_name, "test_") or vim.endswith(file_name, "_test.py")
|
return vim.startswith(file_name, "test_") or vim.endswith(file_name, "_test.py")
|
||||||
end
|
end
|
||||||
@@ -35,14 +34,14 @@ function M.get_python_command(root)
|
|||||||
end
|
end
|
||||||
-- Use activated virtualenv.
|
-- Use activated virtualenv.
|
||||||
if vim.env.VIRTUAL_ENV then
|
if vim.env.VIRTUAL_ENV then
|
||||||
python_command_mem[root] = { Path:new(vim.env.VIRTUAL_ENV, venv_bin, "python").filename }
|
python_command_mem[root] = { vim.fs.joinpath(vim.env.VIRTUAL_ENV, venv_bin, "python") }
|
||||||
return python_command_mem[root]
|
return python_command_mem[root]
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, pattern in ipairs({ "*", ".*" }) do
|
for _, pattern in ipairs({ "*", ".*" }) do
|
||||||
local match = nio.fn.glob(Path:new(root or nio.fn.getcwd(), pattern, "pyvenv.cfg").filename)
|
local match = nio.fn.glob(vim.fs.joinpath(root or nio.fn.getcwd(), pattern, "pyvenv.cfg"))
|
||||||
if match ~= "" then
|
if match ~= "" then
|
||||||
python_command_mem[root] = { (Path:new(match):parent() / venv_bin / "python").filename }
|
python_command_mem[root] = { vim.fs.joinpath(vim.fs.dirname(match), venv_bin, "python") }
|
||||||
return python_command_mem[root]
|
return python_command_mem[root]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -52,7 +51,7 @@ function M.get_python_command(root)
|
|||||||
if success and exit_code == 0 then
|
if success and exit_code == 0 then
|
||||||
local venv = data.stdout:gsub("\r?\n", "")
|
local venv = data.stdout:gsub("\r?\n", "")
|
||||||
if venv then
|
if venv then
|
||||||
python_command_mem[root] = { Path:new(venv).filename }
|
python_command_mem[root] = { venv }
|
||||||
return python_command_mem[root]
|
return python_command_mem[root]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -67,7 +66,7 @@ function M.get_python_command(root)
|
|||||||
if success and exit_code == 0 then
|
if success and exit_code == 0 then
|
||||||
local venv = data.stdout:gsub("\r?\n", "")
|
local venv = data.stdout:gsub("\r?\n", "")
|
||||||
if venv then
|
if venv then
|
||||||
python_command_mem[root] = { Path:new(venv, venv_bin, "python").filename }
|
python_command_mem[root] = { vim.fs.joinpath(venv, venv_bin, "python") }
|
||||||
return python_command_mem[root]
|
return python_command_mem[root]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -80,7 +79,7 @@ function M.get_python_command(root)
|
|||||||
{ stdout = true }
|
{ stdout = true }
|
||||||
)
|
)
|
||||||
if success and exit_code == 0 then
|
if success and exit_code == 0 then
|
||||||
python_command_mem[root] = { Path:new(data).filename }
|
python_command_mem[root] = { data }
|
||||||
return python_command_mem[root]
|
return python_command_mem[root]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -199,7 +198,7 @@ function M.get_runner(python_path)
|
|||||||
then
|
then
|
||||||
return vim_test_runner
|
return vim_test_runner
|
||||||
end
|
end
|
||||||
local runner = M.module_exists("pytest_", python_path) and "pytest"
|
local runner = M.module_exists("pytest", python_path) and "pytest"
|
||||||
or M.module_exists("django", python_path) and "django"
|
or M.module_exists("django", python_path) and "django"
|
||||||
or "unittest"
|
or "unittest"
|
||||||
stored_runners[command_str] = runner
|
stored_runners[command_str] = runner
|
||||||
|
|||||||
Reference in New Issue
Block a user