Closed antoniogamizbadger closed 4 months ago
I have seen this in the docs -> https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings . There is a django
flag, but that only enables support to debug html templates, so it should not affect this behaviour.
I also tried checking if the test file is recognised (see https://github.com/nvim-neotest/neotest-python/issues/52#issuecomment-1676507664), and it is.
Hum, instead of using unittest.TestCase, I have used django.test.TestCase and now the tests are found. Not sure why though. @afrischk I have seend you developed the support for django, so I'm pinging to see if may be you know something about it?
So it seems you can use :echo stdpath("logs")
to get the directory where nvim logs are. In there, you can check neotest.log
. When I took a look there, I found the following:
It seems the mounted volume of the postgres image in my project, has root permissions. So the test finder was looking in that directory and it was triggering an error. What I don't get is why is looking there.
This solves the issue and now the tests are fine. Leaving open in case we can discuss a little bit why that directory is being searched?
django
runner. It should be detected by default though:require("neotest").setup({
adapters = {
require("neotest-python")({
runner = "django"
}),
},
})
The django
test runner works with unittest.TestCase
s and with django.test.TestCase
s that should be no problem.
Do you have __init__.py
files in the test packages? If not, tests will not be found.
You could also use:
is_test_file = function(filename)
return filename:match("test_.+%.py$")
end,
Maybe this helps finding the tests.
Please check if you have configured a DB in the django
settings as the default test runner from django tries to setup the db. Maybe this is an issue here? See: https://github.com/django/django/blob/cfecac27dedc27b5e7f098273787994f49d40037/django/test/runner.py#L1061
The directory is being searched because neotest-python doesn't know where to look for tests. You can configure the filtering with the discovery.filter_dir
option for neotest.setup
but the latest commit of neotest actually already works around errors when reading directories anyway so if you update you should see no problems :smile:
Not sure why this is happening, but I'm running this in a Django project. I'm using the following shortcut:
If I run in a file inheriting from Django test case, like this:
Then the tests are found correctly. Nonetheless, if now I run the same shortcut in a test file where unittest testcase is used, I always get
no tests found
message:So not sure what it's going on. I'm new to neovim, so I may have something incorrect in my config. I tried in a pure unitest project, where django is not involved, and it was working correctly.
This is my neotest config (using lazy.vim), in case it helps: