Closed tbung closed 2 years ago
I'm not seeing this when testing (just tried https://github.com/samuelcolvin/pydantic). Would be great if you can provide a repo :+1:
Ok so further investigating showed it wasn't whether the project is installed, or at least not anymore. The issue is now in what directory nvim is opened. It does not find tests when nvim is opened in the project directory (where setup.cfg etc. are), but it does work one level down in the source directory. For the following test repo, this means it does not work if nvim is open in test-nvim-dap/
but it does if nvim is opened in test-nvim-dap/debugging
.
Test repo here: https://github.com/tbung/test-nvim-dap
I don't seem to be able to reproduce with that unfortunately. Can you provide logs again?
Here it is:
INFO | 2022-07-04T17:12:37Z+0200 | ...te/pack/packer/start/neotest/lua/neotest/client/init.lua:305 | Initialising client
DEBUG | 2022-07-04T17:12:37Z+0200 | .../pack/packer/start/neotest/lua/neotest/lib/file/find.lua:46 | Searching for files using command { "fd", "--type", "f", ".", "/Users/tillb/Projects/test-nvim-dap" }
DEBUG | 2022-07-04T17:12:37Z+0200 | .../pack/packer/start/neotest/lua/neotest/lib/file/find.lua:72 | Searching for files finished
DEBUG | 2022-07-04T17:12:37Z+0200 | ...k/packer/start/neotest/lua/neotest/client/state/init.lua:54 | New positions at ID /Users/tillb/Projects/test-nvim-dap
INFO | 2022-07-04T17:12:37Z+0200 | .../packer/start/neotest/lua/neotest/client/events/init.lua:46 | Emitting discover_positions event
DEBUG | 2022-07-04T17:12:37Z+0200 | .../packer/start/neotest/lua/neotest/client/events/init.lua:48 | Calling listener summary for event discover_positions
DEBUG | 2022-07-04T17:12:37Z+0200 | .../packer/start/neotest/lua/neotest/client/events/init.lua:48 | Calling listener status for event discover_positions
DEBUG | 2022-07-04T17:12:37Z+0200 | .../packer/start/neotest/lua/neotest/client/events/init.lua:48 | Calling listener diagnostic for event discover_positions
I'll investigate if it is some weird interaction with another plugin, I also haven't updated nvim in a couple days, but just to be clear, this only happens if pwd
is ~/Projects/test-nvim-dap
, not if pwd
is ~/Projects/test-nvim-dap/debugging
. If you have any suggestions what I should test, please tell me.
Are you cutting off the logs? There should be a line saying initialisation finished.
Also can you paste your config for neotest/neotest-python?
Nope, that's all there is in the log file, I did not remove anything, just deleted the file, opened neovim, tried running a test, closed neovim and copied the log over.
Here's the config:
use({
"rcarriga/neotest-python",
-- commit = "de234d600e728f2350950355bb5c8d723ea7dff7",
})
use({
"rcarriga/neotest",
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 if it's not finishing initialisation, it looks like something is getting stuck. Since you flagged it on the commit that poetry support, you could take a look at the code https://github.com/nvim-neotest/neotest-python/blob/master/lua/neotest-python/base.lua#L58 and see what's not working. If you want to print, it'll have to be wrapped in vim.schedule
because that code is async. I use this
P = vim.schedule_wrap(function(...)
print(vim.inspect(...))
end)
I also experience this. My config is the same as from @tbung .
Fixing the commit to https://github.com/nvim-neotest/neotest-python/commit/de234d600e728f2350950355bb5c8d723ea7dff7 does indeed resolve the issue.
The repo, I tested this with is https://github.com/Lightning-AI/lightning installed locally with PACKAGE_NAME=pytorch pip install -e .
This is just a wild-guess, but pyproject.toml
isn't poetry-specific (see https://peps.python.org/pep-0621/ and https://pip.pypa.io/en/stable/reference/build-system/pyproject-toml) . So maybe there is no poetry command and since this is run async, this is where it gets stuck. At least for me I can confirm, that I don't have poetry
installed:
$ which poetry
poetry not found
Ah yep looks like it go stuck when poetry wasn't installed. I've pushed a fix, please try now
Can confirm, it works now! Thanks for debugging @justusschock and thanks for the quick fix @rcarriga!
fe5fbe4e344fd1e822eee50d907ebd7aab031d54 breaks test discovery for projects installed with
pip install -e .
. I did not test yet if it also breaks without-e
. If you want I can set up a repo with a minimal project for reproduction. I confirmed it works before installing, and also if I downgrade the plugin.Here is the log, but it doesn't seem to contain anything interesting: