nvim-neotest / nvim-neotest/neotest-python

language name error when running any type of test

Open
#70 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
192
Forks
60
PR merge metrics
No merged PRs in 30d

Description

Error

I get the following error in neotest.log whenever I try to run a single test file or a directory of tests:

WARN | 2024-03-15T23:53:17Z-0700 | ...al/nvim-data/lazy/neotest/lua/neotest/lib/subprocess.lua:164 | CHILD | Error in remote call ...eovim/share/nvim/runtime/lua/vim/treesitter/language.lua:87: '' is not a valid language name
stack traceback:
	[C]: in function 'error'
	...eovim/share/nvim/runtime/lua/vim/treesitter/language.lua:87: in function 'add'
	...m/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:98: in function 'get_string_parser'
	...im-data/lazy/neotest/lua/neotest/lib/treesitter/init.lua:119: in function 'get_parse_root'
	...im-data/lazy/neotest/lua/neotest/lib/treesitter/init.lua:160: in function 'parse_positions_from_string'
	...im-data/lazy/neotest/lua/neotest/lib/treesitter/init.lua:207: in function 'func'
	...al/nvim-data/lazy/neotest/lua/neotest/lib/subprocess.lua:156: in function <...al/nvim-data/lazy/neotest/lua/neotest/lib/subprocess.lua:155>
	[C]: in function 'xpcall'
	...al/nvim-data/lazy/neotest/lua/neotest/lib/subprocess.lua:155: in function <...al/nvim-data/lazy/neotest/lua/neotest/lib/subprocess.lua:154>

all errors in the log file are the same as above, apart from 2 instances of this:

WARN | 2024-03-15T23:26:14Z-0700 | ...al/nvim-data/lazy/neotest/lua/neotest/lib/subprocess.lua:164 | CHILD | Error in remote call error converting argument 4
stack traceback:
	[C]: in function 'rpcnotify'
	...al/nvim-data/lazy/neotest/lua/neotest/lib/subprocess.lua:126: in function 'notify'
	...al/nvim-data/lazy/neotest/lua/neotest/lib/subprocess.lua:165: in function <...al/nvim-data/lazy/neotest/lua/neotest/lib/subprocess.lua:162>
	[C]: in function 'error'
	...eovim/share/nvim/runtime/lua/vim/treesitter/language.lua:87: in function 'add'
	...m/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:98: in function 'get_string_parser'
	...im-data/lazy/neotest/lua/neotest/lib/treesitter/init.lua:119: in function 'get_parse_root'
	...im-data/lazy/neotest/lua/neotest/lib/treesitter/init.lua:160: in function 'parse_positions_from_string'
	...im-data/lazy/neotest/lua/neotest/lib/treesitter/init.lua:207: in function 'func'
	...al/nvim-data/lazy/neotest/lua/neotest/lib/subprocess.lua:156: in function <...al/nvim-data/lazy/neotest/lua/neotest/lib/subprocess.lua:155>
	[C]: in function 'xpcall'
	...al/nvim-data/lazy/neotest/lua/neotest/lib/subprocess.lua:155: in function <...al/nvim-data/lazy/neotest/lua/neotest/lib/subprocess.lua:154>
Details

nvim --version:

NVIM v0.9.5
Build type: RelWithDebInfo
LuaJIT 2.1.1703942320
Compilation: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe /MD /Zi /O2 /Ob1  -W3 -wd4311 -wd4146 -DUNIT_TESTING -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_WIN32_WINNT=0x0602 -DMSWIN -DINCLUDE_GENERATED_DECLARATIONS -ID:/a/neovim/neovim/.deps/usr/include/luajit-2.1 -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/build/src/nvim/auto -ID:/a/neovim/neovim/build/include -ID:/a/neovim/neovim/build/cmake.config -ID:/a/neovim/neovim/src -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include
-ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include

   system vimrc file: "$VIM\sysinit.vim"
  fall-back for $VIM: "C:/Program Files (x86)/nvim/share/nvim"

The project is managed using Poetry and has the following structure. Running poetry run pytest outside of nvim runs fine:

image

Im using lazyvim and have installed neotest using the extras package, but I have also tested this manually with this config:

return {
  {
    "folke/neodev.nvim",
    opts = {
      library = {
        plugins = { "neotest" },
        types = true,
      },
    },
  },
  {
    "nvim-neotest/neotest",
    dependencies = {
      "nvim-lua/plenary.nvim",
      "antoinemadec/FixCursorHold.nvim",
      "nvim-treesitter/nvim-treesitter",
      "nvim-neotest/neotest-go",
      "nvim-neotest/neotest-python",
    },
    opts = {
      default_strategy = "integrated",
      discovery = {
        enabled = true,
      },
      adapters = {
        require("neotest-go"),
        require("neotest-python")({
          runner = "pytest",
          python = "C:\\Users\\simon\\AppData\\Local\\pypoetry\\Cache\\virtualenvs\\herald-of-completion-NCjgh5TX-py3.11\\Scripts",
          -- python = ".venv/bin/python",
        }),
      },
    },
  },
}

all of my venvs are in the default poetry directory (rather than in separate project directories). I activate the relevant venv using venv-selector

it seems that test discovery works fine as the summary window shows them all correctly, just nothing happens (apart from the logged error) when I run require("neotest").run.run(vim.fn.expand("%"))

image

given how often treesitter appears in the log, I also tried recompiling the grammar for python but that didn't fix the problem

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with require("neotest").run.run(vim.fn.expand("%")) using the reported neotest-python Poetry configuration. Start with neotest/lib/treesitter/init.lua and subprocess.lua in the traceback, then inspect how the Python adapter supplies language information during test execution. Done means running a file or directory completes without the invalid language-name or RPC errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua, python, vim
Domain
testing-qa, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.