emacs-python-pytest icon indicating copy to clipboard operation
emacs-python-pytest copied to clipboard

Use tree sitter for getting the node id (aka test id) for the function and class at point

Open rodrigo-morales-1 opened this issue 1 year ago • 6 comments

The master branch uses the function python-pytest--current-defun for getting the test id of the function at point or class at point and it supports at most 2 parts. The changes in this pull request adds two functions: python-pytest--node-id-def-at-point (link) and python-pytest--node-id-class-at-point (link) which get the path for the def or class at point for an arbitrary number of nested classes, these two functions use tree-sitter. See the file tests/test-python-helpers.el (link to file) for examples on how these functions behave. By having two functions for different purposes, the user has more control over what to execute (e.g. (s)he could execute a Test class when the point is on a function).

Please let me know what you think of these changes, so that I can improve this pull request to suit more use cases.

rodrigo-morales-1 avatar Aug 12 '24 19:08 rodrigo-morales-1