-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No tests found if running from a non-test file #40
Comments
It sounds like a project root is not being found and thus parsing isn't started until a test buffer is opened, which would be expected behaviour. The adapter looks for certain files to determine the project root (can be found here https://github.com/rcarriga/neotest-python/blob/52624d1306cb2b401aa72c1d0bee90438916ba7d/lua/neotest-python/init.lua#L72). The summary not updating to say |
I will test it in about 3h, but an idea came to me that maybe the reason was because there was no |
So I double-checked with initializing git repo, and then ran nvim in verbose mode, and this is what I got regarding neotest-summary:
and that's about it. |
Or maybe that's not the log that I was supposed to paste :P Sorry, but I could not find info on where is the vim.log stored, if it is different from the runtime log |
I think, you gave the answer to the question:
As soon as I added any of those files, it recognized the tests. So to reproduce it, just create a subfolder without any of those files. Question 1: Could we add Here's the log that you were asking for. For future reference: it is stored in
|
Yep that's exactly the expected behaviour 👍
Not by default no, otherwise this adapter would be started every time neotest was started. The adapters are specifically designed to only use root patterns that are specific to them. Even if this was configurable I wouldn't suggest doing that, you'll run into neotest trying to parse random directories which could significantly impact the editor depending on size. My suggestion would be to just create one of those config files if you're working in a directory that you normally have test files inside (they don't have to contain anything) or to setup some autocmd to open one of the test files in a buffer so that when neotest starts, it will know that the python adapter should be use. |
Great, thanks, will bear that in mind |
Hey, I know this might be self explanatory, but hear me out ;)
So let's say I have the following folder structure:
If I open either
test_foo.py
ortest_bar.py
and run:lua require'neotest'.summary.toggle()
, it will successfully parse all tests (including the other not-opened-yet test files). I can then run the tests from the summary, all is totally fine.The problem:
If I try to do the same from
main.py
(let's say that I don't have other buffers open yet), it will parse the tests forever ('Parsing tests'). If I close and reopen the summary, it will finally tell me that it could not find any tests. All is fixed again, if I open any test file, but as you can imagine, it is far from optimal :(The question is, is it a bug, is it an enhancement request, or can it be solved with a better
.is_test_file()
?The text was updated successfully, but these errors were encountered: