LazyVim / LazyVim

Neovim config for the lazy
https://lazyvim.github.io/
Apache License 2.0
17.71k stars 1.25k forks source link

bug: Python tests stop working after enabling extras.lang.go #4398

Closed odaven closed 2 months ago

odaven commented 3 months ago

Did you check docs and existing issues?

Neovim version (nvim -v)

0.10.1 Build type: Release LuaJIT 2.1.1724512491

Operating system/version

MacOs Ventura 13.6.9

Describe the bug

At the point of writing this bug the LazyVim version is 12.38.2

Using LazyVim in a python project with only enabling extras extras.lang.python and extras.test.core.

Starting tests with shortcuts as <leader>tr work as expected. The other variants like Run File and Run All Test Files work also.

After installing extras.lang.go those tests stop working and there is a popup showing No test found. The command Run All Test Files <leader>tT shows the below message even though this is a Python project.

Screenshot 2024-09-03 at 21 52 53



The issue happens with a new LazyVim installation where the only extras enabled are:

Screenshot 2024-09-03 at 22 16 26



In the other side, the Go project works without issues and test commands work as expected

Other languages I usually use that didn't show this issue are:

    "lazyvim.plugins.extras.lang.json",
    "lazyvim.plugins.extras.lang.markdown",
    "lazyvim.plugins.extras.lang.python",
    "lazyvim.plugins.extras.lang.terraform",
    "lazyvim.plugins.extras.lang.typescript",
    "lazyvim.plugins.extras.lang.yaml",

Steps To Reproduce

  1. New LazyVim installation
  2. Open Python project
  3. Install extras.lang.python and extras.test.core
  4. Run tests succesfully
  5. Enable extras.lang.go and restart
  6. Test won't run.
  7. Disable extras.lang.go and restart
  8. Tests work again

Expected Behavior

I expect that having python and go extras enabled at the same time and getting the tests working as expected in projects with those languages.

Repro

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
  spec = {
    { "LazyVim/LazyVim", import = "lazyvim.plugins" },
    -- add any other plugins here
  },
})
dpetka2001 commented 3 months ago

This seems to be a bug with neotest itself. Following screencast

Screencast_2024-09-04-12-57-31.webm

Minimal init.lua to reproduce without LazyVim

-- init.lua
-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
    vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
-- local lazypath = vim.fn.expand("~/projects/plugins/lazy.nvim/")
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath })
end
vim.opt.runtimepath:prepend(lazypath)

vim.opt.ignorecase = true
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2

vim.g.mapleader = " "

-- install plugins
local plugins = {
    { "folke/tokyonight.nvim" },
    {
        "nvim-treesitter/nvim-treesitter",
        build = ":TSUpdate",
        opts = {
            ensure_installed = {
                "python",
                "go",
                "gomod",
                "gowork",
                "gosum",
            },
        },
        config = function(_, opts)
            require("nvim-treesitter.configs").setup(opts)
        end,
    },
    {
        "folke/which-key.nvim",
        opts = {},
    },
    {
        "nvim-neotest/neotest",
        dependencies = {
            "nvim-neotest/nvim-nio",
            "nvim-lua/plenary.nvim",
            "antoinemadec/FixCursorHold.nvim",
            "nvim-neotest/neotest-python",
            "fredrikaverpil/neotest-golang",
        },
        keys = {
            { "<leader>t", "", desc = "+test" },
            {
                "<leader>tt",
                function()
                    require("neotest").run.run(vim.fn.expand("%"))
                end,
                desc = "Run File",
            },
            {
                "<leader>tT",
                function()
                    require("neotest").run.run(vim.uv.cwd())
                end,
                desc = "Run All Test Files",
            },
            {
                "<leader>tr",
                function()
                    require("neotest").run.run()
                end,
                desc = "Run Nearest",
            },
            {
                "<leader>tl",
                function()
                    require("neotest").run.run_last()
                end,
                desc = "Run Last",
            },
            {
                "<leader>ts",
                function()
                    require("neotest").summary.toggle()
                end,
                desc = "Toggle Summary",
            },
            {
                "<leader>to",
                function()
                    require("neotest").output.open({ enter = true, auto_close = true })
                end,
                desc = "Show Output",
            },
            {
                "<leader>tO",
                function()
                    require("neotest").output_panel.toggle()
                end,
                desc = "Toggle Output Panel",
            },
            {
                "<leader>tS",
                function()
                    require("neotest").run.stop()
                end,
                desc = "Stop",
            },
            {
                "<leader>tw",
                function()
                    require("neotest").watch.toggle(vim.fn.expand("%"))
                end,
                desc = "Toggle Watch",
            },
        },
        config = function()
            require("neotest").setup({
                adapters = {
                    require("neotest-python")({}),
                    require("neotest-golang")({}),
                },
            })
        end,
    },
    -- add any other plugins here
}
require("lazy").setup(plugins, {
    root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

Put it in the folder with your Python files and run it with nvim -u init.lua test_whatever.py.