Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect pytest from pyproject.toml #144

Merged
merged 2 commits into from
Jun 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions lua/dap-python.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ local function default_runner()
return 'pytest'
elseif uv.fs_stat('manage.py') then
return 'django'
elseif uv.fs_stat("pyproject.toml") then
local f = io.open("pyproject.toml")
if f then
for line in f:lines() do
if line:find("%[tool.pytest") then
f:close()
return "pytest"
end
end
f:close()
end
else
return 'unittest'
end
Expand Down Expand Up @@ -146,17 +157,11 @@ end

---@return string[]
local function flatten(...)
local argc = select("#", ...)
local result = {}
for i = 1, argc do
local arg = select(i, ...)
if type(arg) == "table" then
vim.list_extend(result, arg)
else
table.insert(result, arg)
end
local values = {...}
if vim.iter then
return vim.iter(values):flatten(2):totable()
end
return result
return vim.tbl_flatten(values)
end


Expand Down
Loading