From f48dbfa52b69696f11d3696f1fa3ae582584ab16 Mon Sep 17 00:00:00 2001 From: Sam Castelain Date: Fri, 3 Jul 2026 09:01:22 +0200 Subject: [PATCH] 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 --- lua/neotest-python/base.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lua/neotest-python/base.lua b/lua/neotest-python/base.lua index 0ac3ddd..315bc94 100644 --- a/lua/neotest-python/base.lua +++ b/lua/neotest-python/base.lua @@ -110,6 +110,20 @@ end ---@return string local function scan_test_function_pattern(runner, config, python_command) 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 end