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
Feature request - Add tab completion for test classes and functions #7329
Comments
Hi @timhoffm! I think AST should be preferred, as importing files always has the chance of executing side-effects. 👍 |
Without import we can only handle simple cases |
Indeed, tests generated at runtime would not be found then. |
From my experience, generated tests are a niche application, but YMMV. It would not be the end of the world if tab completion cannot find them 😄. OTOH pytest will import the modules for test discovery. Side effects will be run then anyway. The only reason I see for not import for completion would be that such side effects could be slow and thus slow down the completer. |
for tab completion i would propose to simply import and collect once |
Could this be related to #5514? Also, possibly related: I've pondered how to select tests to run via fuzzy autocompletion, maybe building on fzf. I think that would require a cache of collected tests. Without looking at the current autocomplete implementation, I wonder if that cache could be useful for this issue as well. |
Yes, this is essentially the same as #5514. |
@bhrutledge : for what it's worth, I wrote a small program (brilliantly named testfinder) that helps me do that. Basically, it parses all Python test files and prints pytest-compatible "paths" for all test classes, methods and functions. You can then feed that to |
Pytest can tab-complete for running individual files
It would be great to extend the completion to classes and functions
AFAICS it should be relatively straight forward to extend
FastFilesCompleter
for that. I may get around implemting this at some point.Question: would it be ok for the completer to import the
test_file.py
or should we parse the contents via AST?The text was updated successfully, but these errors were encountered: