nvim-neotest / neotest

An extensible framework for interacting with tests within NeoVim.
MIT License
2.35k stars 115 forks source link

Can't open neotest.py, Windows #118

Closed Balandino closed 2 years ago

Balandino commented 2 years ago

Hello,

I'm trying to setup neotest on my Windows neovim and am hitting some problems. I'm using the following packer command:

use({
          'nvim-neotest/neotest',
          requires = {
             'nvim-lua/plenary.nvim',
             'nvim-treesitter/nvim-treesitter',
             'antoinemadec/FixCursorHold.nvim',
             'nvim-neotest/neotest-python',
          },
       })

And the following configuration:

require('neotest').setup({
   adapters = {
      require('neotest-python')({
         runner = 'unittest',
         python = 'python',
      }),
   },
})

When I open up a simple python file with unit tests and run

lua require("neotest").run.run()

If I position my cursor next to one of the tests before running I receive a floating window stating:

C:\path\to\python\python.exe Can't open file 'C:\\Users\\Username\\AppData\\Local\\nvim-data\\site\\pack\\packer\\neotest.py: [Errno 2] No such file or directory.

neotest.py is currently installed here:

C:\Users\Username\AppData\Local\nvim-data\site\pack\packer\start\neotest-python

So I am assuming that somehow my configuration is pointed to the wrong place, but am unsure how to correct this. Any help or guidance here would be appreciated.

As a side note, when the test runs a yellow icon appears in the gutter before quickly turning red (a small question mark in a diamond) which looks like something my font can't display, although I believe I'm using a nerdfont (Firacode NF) and can see the symbols used for test completion failure/success in the documentation, so am unsure why this symbol seems to be undisplayable. I am presuming that it is linked to the issue mentioned above.

rcarriga commented 2 years ago

I think I've fixed this if you could try the latest version of neotest-python. I don't use Windows so I haven't tested this adapter on it unfortunately so you may run into other issues. Please let me know and I'll do my best to address!

As a side note, when the test runs a yellow icon appears in the gutter before quickly turning red (a small question mark in a diamond) which looks like something my font can't display,

This was due to outdated docs, the icons by default now use vscode-codicons because nerd fonts doesn't exclusively use private codes which can cause conflicts.

Balandino commented 2 years ago

Hello,

I'm still trying to fiddle the icons, but after the update it looks like the path displayed when I try to run a test has changed to

C:\path\to\python\python.exe Can't open file 'C:\\Users\\Username\\AppData\\Local\\nvim-data\\site\\pack\\packer\\start\\neotest.py: [Errno 2] No such file or directory.

So is likely still slightly off. Thanks for trying to fix this, I appreciate that it is a bit like coding blind if you don't have a Windows device to access.

rcarriga commented 2 years ago

OK I've changed how the script is located to search the runtime path so it should fix the issue

Balandino commented 2 years ago

Success!

The tests now turn green or red dependant on their outcome and that is reflected in the summary window as well. The icons still don't properly show, but I believe that is down to the font change you previously mentioned so is a separate issue that I will have to change in my terminal.

Thanks for the changes.