nvim-neotest / neotest-python

MIT License
136 stars 40 forks source link

Possible conflict in deps between neotest and neotest-python #78

Closed ShouryaRSharma closed 2 months ago

ShouryaRSharma commented 2 months ago

I'm fairly sure there is a conflict between neotest-python and neotest since a global function is failing to run. When I attempt to debug any tests with pytest I get the following error:

neotest-python: ...k/lazy/opt/neotest-python/lua/neotest-python/adapter.lua:100: attempt to call global 'P' (a nil value)
stack traceback:
        ...m/site/pack/lazy/opt/neotest/lua/neotest/client/init.lua:89: in function 'P'
        ...k/lazy/opt/neotest-python/lua/neotest-python/adapter.lua:100: in function 'build_spec'
        ...site/pack/lazy/opt/neotest/lua/neotest/client/runner.lua:76: in function '_run_tree'
        ...site/pack/lazy/opt/neotest/lua/neotest/client/runner.lua:65: in function <...site/pack/lazy/opt/neotest/lua/neotest/client/runner.lua:22>
        [C]: in function 'xpcall'
        ...m/site/pack/lazy/opt/neotest/lua/neotest/client/init.lua:84: in function 'run_tree'
        ...site/pack/lazy/opt/neotest/lua/neotest/consumers/run.lua:85: in function 'func'
        ...e/lunarvim/site/pack/lazy/opt/nvim-nio/lua/nio/tasks.lua:173: in function <...e/lunarvim/site/pack/lazy/opt/nvim-nio/lua/nio/tasks.lua:172>

My lunarvim config is as follows:

lvim.plugins = {
  {
    "nvim-treesitter/nvim-treesitter-textobjects",
    dependencies = "nvim-treesitter/nvim-treesitter",
  },
  {
    "mfussenegger/nvim-dap-python",
  },
  {
    "TimUntersberger/neogit",
    dependencies = "nvim-lua/plenary.nvim",
    cmd = "Neogit",
    config = function()
      require("neogit").setup({
        integrations = {
          diffview = true
        }
      })
    end
  },
  {
    "nvim-neotest/neotest",
    dependencies = {
      "nvim-neotest/nvim-nio",
      "nvim-lua/plenary.nvim",
      "antoinemadec/FixCursorHold.nvim",
      "nvim-treesitter/nvim-treesitter"
    },
  },
  {
    "nvim-neotest/neotest-python",
  },
  {
    "hdiniz/vim-gradle",
    ft = {"gradle", "groovy"},
  },
}

require("neotest").setup({
  adapters = {
    require("neotest-python")({
      -- Extra arguments for nvim-dap configuration
      -- See https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for values
      dap = {
        justMyCode = false,
        console = "integratedTerminal",
      },
      args = { "--log-level", "DEBUG", "--quiet", "-vvv"},
      runner = "pytest",
    })
  }
})

lvim.builtin.which_key.mappings["d"]["]"] = {
  name = "Testing",
  p = {
    name = "Python",
    m = { "<cmd>lua require('neotest').run.run()<cr>", "Test Method" },
    M = { "<cmd>lua require('neotest').run.run({strategy = 'dap'})<cr>", "Test Method DAP" },
    f = { "<cmd>lua require('neotest').run.run({vim.fn.expand('%')})<cr>", "Test File" },
    F = { "<cmd>lua require('neotest').run.run({vim.fn.expand('%'), strategy = 'dap'})<cr>", "Test File DAP" },
  },
  j = {
    name = "Java",
    s = { "<cmd>lua require'jdtls'.test_class()<CR>", "Test Class" },
    m = { "<cmd>lua require'jdtls'.test_nearest_method()<CR>", "Test Method" },
  },
  S = { "<cmd>lua require('neotest').summary.toggle()<cr>", "Test Summary" },
}
ohseunghyeon commented 2 months ago

I have this problem too

neotest-python: .../nvim/lazy/neotest-python/lua/neotest-python/adapter.lua:100: attempt to call global 'P' (a nil value)
stack traceback:
    ...ocal/share/nvim/lazy/neotest/lua/neotest/client/init.lua:89: in function 'P'
    .../nvim/lazy/neotest-python/lua/neotest-python/adapter.lua:100: in function 'build_spec'
    ...al/share/nvim/lazy/neotest/lua/neotest/client/runner.lua:76: in function '_run_tree'
    ...al/share/nvim/lazy/neotest/lua/neotest/client/runner.lua:65: in function <...al/share/nvim/lazy/neotest/lua/neotest/client/runner.lua:22>
    [C]: in function 'xpcall'
    ...ocal/share/nvim/lazy/neotest/lua/neotest/client/init.lua:84: in function 'run_tree'
    ...al/share/nvim/lazy/neotest/lua/neotest/consumers/run.lua:85: in function 'func'
    ...yeonoh/.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:173: in function <...yeonoh/.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:172>