Skip to content
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

fix: no tests found bug in python files #89

Closed
wants to merge 1 commit into from

Conversation

olisikh
Copy link

@olisikh olisikh commented Jan 3, 2025

It appears that the get_root function was unable to find the root folder, so tests in Python scripts were not executed, because neotest did not even try to discover them.

To fix that, I defined a get_root local function and reused it across the adapter.
This fixed an issue for me and I assume it should fix issue #83.

With this change, neotest-python discovers tests even if there are no special python files specified in a root folder.

@olisikh olisikh force-pushed the fix/no_tests_found branch from cde9b13 to 80c9658 Compare January 3, 2025 00:32
@olisikh olisikh force-pushed the fix/no_tests_found branch from 80c9658 to ff316aa Compare January 3, 2025 00:33
@rcarriga
Copy link
Collaborator

rcarriga commented Jan 3, 2025

This is very purposefully the case, otherwise when neotest is starting up and neotest-python says the current directory is the root, it will start scanning every file in the current directory which would not be desirable if opened in say the home directory.

If you really want to do this instead of just creating the files it looks for, you can do something like this

local custom_adapter = require("neotest-python")({})
local base_root = custom_adapter.root
custom_adapter.root = function(path)
  return base_root(path) or vim.loop.cwd() or ""
end

@rcarriga rcarriga closed this Jan 3, 2025
@olisikh olisikh deleted the fix/no_tests_found branch January 3, 2025 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants