Skip to content

Commit 5d1aa24

Browse files
authored
ensure pytest at point works with class methods (#503)
1 parent 3c4bb90 commit 5d1aa24

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

dap-python.el

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ https://github.com/pyenv/pyenv-which-ext."
8888
(lsp-defun dap-python--parse-lsp-symbol
8989
((&DocumentSymbol
9090
:name :kind
91-
:selection-range (&Range :start (&Position :line start-line
91+
:range (&Range :start (&Position :line start-line
9292
:character start-character)
9393
:end (&Position :line end-line
9494
:character end-character))))
@@ -113,7 +113,8 @@ https://github.com/pyenv/pyenv-which-ext."
113113

114114
(defun dap-python--test-p (lsp-symbol)
115115
(let ((name (dap-python--symbol-name lsp-symbol)))
116-
(and (string= (dap-python--symbol-type lsp-symbol) "Function")
116+
(and (or (string= (dap-python--symbol-type lsp-symbol) "Function")
117+
(string= (dap-python--symbol-type lsp-symbol) "Method"))
117118
(s-starts-with? "test_" name))))
118119

119120
(defun dap-python--test-class-p (test-symbol lsp-symbol)
@@ -142,6 +143,7 @@ https://github.com/pyenv/pyenv-which-ext."
142143

143144
(defun dap-python--test-at-point ()
144145
(->> (lsp--get-document-symbols)
146+
(lsp--symbols->document-symbols-hierarchy)
145147
(mapcar #'dap-python--parse-lsp-symbol)
146148
(dap-python--symbols-before-point (dap-python--cursor-position))
147149
dap-python--nearest-test))

0 commit comments

Comments
 (0)