From 304cee02233d16050331f5edc9b99d25251d9631 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3n=C3=A1n=20Carrigan?= Date: Wed, 8 Jun 2022 21:24:03 +0100 Subject: [PATCH] fix: allow files ending in _test See #3 --- lua/neotest-python/base.lua | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/lua/neotest-python/base.lua b/lua/neotest-python/base.lua index 4f9f6fb..634f579 100644 --- a/lua/neotest-python/base.lua +++ b/lua/neotest-python/base.lua @@ -10,7 +10,7 @@ function M.is_test_file(file_path) end local elems = vim.split(file_path, Path.path.sep) local file_name = elems[#elems] - return vim.startswith(file_name, "test_") + return vim.startswith(file_name, "test_") or vim.endswith(file_name, "_test.py") end M.module_exists = function(module, python_command) @@ -42,18 +42,4 @@ function M.get_python_command(root) return { async.fn.exepath("python3") or async.fn.exepath("python") or "python" } end -function M.parse_positions(file_path) - local query = [[ - ((function_definition - name: (identifier) @test.name) - (#match? @test.name "^test_")) - @test.definition - - (class_definition - name: (identifier) @namespace.name) - @namespace.definition - ]] - return lib.treesitter.parse_positions(file_path, query) -end - return M