Hi, running the test_method method on an async python test raises an error in neovim. The method looks something like this:
async def test_something():
await some_async_method()
<checks, not relevant for this issue>
If I try to run this test I get the following error:
E5108: Error executing lua ...local/share/nvim/lazy/nvim-dap-python/lua/dap-python.lua:336: assertion failed!
stack traceback:
[C]: in function 'assert'
...local/share/nvim/lazy/nvim-dap-python/lua/dap-python.lua:336: in function '_get_nodes'
...local/share/nvim/lazy/nvim-dap-python/lua/dap-python.lua:423: in function 'test_method'
[string ":lua"]:1: in main chunk
I took a quick look at the code around line 336 and I think that the failing assertion doesn't take async methods into account. It verifies if the second child element of the parent node is an identifier:
local ident = parent:child(1)
assert(ident:type() == "identifier")
With an async method this breaks as the second child element is actually the 'def' element. In that case I think it should verify the third child element. I tried it out by locally modifying the code on line 335 to
local ident = parent:child(2)
assert(ident:type() == "identifier")
This resolved the issue and I could successfully run the test.
Hi, running the
test_method
method on an async python test raises an error in neovim. The method looks something like this:If I try to run this test I get the following error:
I took a quick look at the code around line 336 and I think that the failing assertion doesn't take async methods into account. It verifies if the second child element of the parent node is an identifier:
With an async method this breaks as the second child element is actually the 'def' element. In that case I think it should verify the third child element. I tried it out by locally modifying the code on line 335 to
This resolved the issue and I could successfully run the test.
I'm using pytest as test_runner in my setup.