Closed tbung closed 2 years ago
Maybe you can tell if there is an obvious reason for this @stevearc.
I'm not seeing this issue, could you provide your config for neotest and neotest-python?
Ya, I also can only reproduce it in this one project and not in an attempt of a minimal example, with the previous commit both work, I have no clue why. I will investigate further and report back.
Here is the config, I'll provide an example once I know what makes this one project special:
use("rcarriga/neotest-python")
use({
"rcarriga/neotest",
-- commit = "0cabaff54051474c997964b0fdfc5d95dc35dbfd",
requires = {
"nvim-lua/plenary.nvim",
"nvim-treesitter/nvim-treesitter",
"antoinemadec/FixCursorHold.nvim",
},
config = function()
require("neotest").setup({
output = {
enabled = true,
open_on_run = "yes",
},
adapters = {
require("neotest-python")({
runner = "pytest",
-- dap = { justMyCode = false, console = "integratedTerminal" },
}),
},
})
end,
})
Ok, so I investigated further, and the latest commit fails if there is a comment after the test, at least in python. This only happens the first time you try to run the test, once it has found the test you can add the comment and it works. The following example reproduces this for me, if you remove the comment everything works.
import pytest
def fib(n: int) -> int:
if n < 2:
return n
else:
return fib(n - 1) + fib(n - 2)
@pytest.mark.parametrize(
("input", "expected"), [(0, 0), (1, 1), (2, 1), (3, 2), (4, 3), (5, 5), (10, 55)]
)
def test_fib(input: int, expected: int):
assert fib(input) == expected
# test
Actually, it can't handle any comments in the code, no matter where you put it.
OK I can reproduce with that thanks! Will investigate further
Ah found this https://github.com/neovim/neovim/issues/18790 which is the same issue. Was fixed in master 8 days ago so just updating NeoVim will fix
Afaik im on neovim/neovim@6eaf10502c99e96704daa07987f73658d6c4d68a so second to latest commit and can still reproduce the issue. Is it fixed for you? Maybe I gotta delete ~/.local/nvim
.
I was able to repro this in the commit right before the fix (d93ba03c717bee05fe6d239fd7faefe6e9698c85), but when I update to e15d31b53 and rebuild the issue goes away
Yep can confirm it worked for me once I updated
Yup, works for me now, too. Thanks, you guys!
If I have any comments in a python test file, I'm still seeing the problem above, with the latest everything:
neovim
: neovim/neovim@6d52a29neotest
: nvim-neotest/neotest@fcf2468neotest-python
: nvim-neotest/neotest-python@de234d6nvim-treesitter
: nvim-treesitter/nvim-treesitter@8eccd82I'm seeing this error show up in ~/.local/state/nvim/neotest.log
:
ERROR | 2022-06-22T13:51:16Z+1000 | ...te/pack/packer/start/neotest/lua/neotest/client/init.lua:419 | Couldn't find positions in path /home/josh/scratch/test_fib.py ...r/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:115: Ranges can only be made from 6 element long tables or nodes.
Can't reproduce unfortunately, can't really offer any advice except try wiping the neovim (make sure to start from fresh when building too make distclean
) install and re-installing.
thanks @rcarriga - I've tried a fresh rebuild, installing nightly using nix
and even the nightly nvim.appimage
but I get the same effect.
I even reinstalled the python tree-sitter parser :)
If I figure out what's different, I'll post here!
You can check your runtime files to see if the fix is present (you can see it's just a small change https://github.com/neovim/neovim/pull/18794/files) as well. If it is then it might be worth re-raising. I can help with creating a reproduction
Ugh - I'm sorry for the noise - I've got it working now!
I think what has happened is that a stray LD_LIBRARY_PATH
in my .profile
left over from an experiment was picking up a different version of libtree-sitter.so
, which was producing an unexpected structure. Looking at the critical code you posted above and what it is doing helped trigger that chain of thought - thank you @rcarriga :)
Ah good to hear :+1:
The latest commit 05a700f866e31f12b2d3144ecc437f77d4af531a breaks test discovery in python for me. Everything works fine with the commit before that. I'll test a bit if it affects all tests or just specific strings, maybe even pytest decorators.