chore: Replace use of deprecated vim.tbl_flatten (#112)

vim.tbl_flatten is deprecated and will be removed in 0.13. Just replaced
it with the recommendation in the deprecation notice.

For some reason discovering tests did not work anymore after upgrading from
0.11.x to 0.12.1 even though vim.tbl_flatten still works in this
version. Replacing it fixes test discovery for me though and it needs to
be done before 0.13 anyway.

Co-authored-by: Sam Castelain <sam@secury-360.com>
This commit is contained in:
Sam Castelain
2026-08-18 16:40:31 +03:00
committed by Itai Bohadana
co-authored by Sam Castelain
parent 460afdf404
commit f48dbfa52b
+14
View File
@@ -110,6 +110,20 @@ end
---@return string ---@return string
local function scan_test_function_pattern(runner, config, python_command) local function scan_test_function_pattern(runner, config, python_command)
local test_function_pattern = "^test" local test_function_pattern = "^test"
if runner == "pytest" and config.pytest_discovery then
local cmd = vim
.iter({ python_command, M.get_script_path(), "--pytest-extract-test-name-template" })
:flatten()
:totable()
local _, data = lib.process.run(cmd, { stdout = true, stderr = true })
for line in vim.gsplit(data.stdout, "\n", true) do
if string.sub(line, 1, 1) == "{" and string.find(line, "python_functions") ~= nil then
local pytest_option = vim.json.decode(line)
test_function_pattern = pytest_option.python_functions
end
end
end
return test_function_pattern return test_function_pattern
end end