@@ -84,35 +84,6 @@ https://github.com/pyenv/pyenv-which-ext."
8484 (type nil :type string)
8585 (location nil :type dap-python--location))
8686
87- (cl-defgeneric dap-python--equal (lhs rhs)
88- (:documentation " Check if lhs and rhs are equal" ))
89-
90- (cl-defmethod dap-python--equal ((lhs symbol) (rhs symbol))
91- (eq lhs rhs))
92-
93- (cl-defmethod dap-python--equal ((lhs integer) (rhs integer))
94- (eq lhs rhs))
95-
96- (cl-defmethod dap-python--equal ((lhs string) (rhs string))
97- (string-equal lhs rhs))
98-
99- (cl-defmethod dap-python--equal ((lhs list ) (rhs list ))
100- (and (dap-python--equal (length lhs) (length rhs))
101- (-reduce (lambda (x y ) (and x y)) (-zip-with 'dap-python--equal lhs rhs))))
102-
103- (cl-defmethod dap-python--equal ((lhs dap-python--point) (rhs dap-python--point))
104- (and (dap-python--equal (dap-python--point-line lhs) (dap-python--point-line rhs))
105- (dap-python--equal (dap-python--point-character lhs) (dap-python--point-character rhs))))
106-
107- (cl-defmethod dap-python--equal ((lhs dap-python--location) (rhs dap-python--location))
108- (and (dap-python--equal (dap-python--location-start lhs) (dap-python--location-start rhs))
109- (dap-python--equal (dap-python--location-end lhs) (dap-python--location-end rhs))))
110-
111- (cl-defmethod dap-python--equal ((lhs dap-python--symbol) (rhs dap-python--symbol))
112- (and (dap-python--equal (dap-python--symbol-name lhs) (dap-python--symbol-name rhs))
113- (dap-python--equal (dap-python--symbol-type lhs) (dap-python--symbol-type rhs))
114- (dap-python--equal (dap-python--symbol-location lhs) (dap-python--symbol-location rhs))))
115-
11687(lsp-defun dap-python--parse-lsp-symbol
11788 ((&DocumentSymbol
11889 :name :kind
@@ -141,17 +112,17 @@ https://github.com/pyenv/pyenv-which-ext."
141112
142113(defun dap-python--test-p (lsp-symbol )
143114 (let ((name (dap-python--symbol-name lsp-symbol)))
144- (and (dap-python--equal (dap-python--symbol-type lsp-symbol) " Function" )
145- (s-starts-with? " test_" name))))
115+ (and (string= (dap-python--symbol-type lsp-symbol) " Function" )
116+ (s-starts-with? " test_" name))))
146117
147118(defun dap-python--test-class-p (test-symbol lsp-symbol )
148- (when (dap-python--equal (dap-python--symbol-type lsp-symbol) " Class" )
119+ (when (string= (dap-python--symbol-type lsp-symbol) " Class" )
149120 (let* ((class-location (dap-python--symbol-location lsp-symbol))
150- (class-start-line (-> class-location dap-python--location-start dap-python--point-line))
151- (class-end-line (-> class-location dap-python--location-end dap-python--point-line))
152- (test-start-line (-> test-symbol dap-python--symbol-location dap-python--location-start dap-python--point-line)))
153- (and (> test-start-line class-start-line)
154- (< test-start-line class-end-line)))))
121+ (class-start-line (-> class-location dap-python--location-start dap-python--point-line))
122+ (class-end-line (-> class-location dap-python--location-end dap-python--point-line))
123+ (test-start-line (-> test-symbol dap-python--symbol-location dap-python--location-start dap-python--point-line)))
124+ (and (> test-start-line class-start-line)
125+ (< test-start-line class-end-line)))))
155126
156127(defun dap-python--nearest-test (lsp-symbols )
157128 (cl-callf reverse lsp-symbols)
@@ -175,11 +146,14 @@ https://github.com/pyenv/pyenv-which-ext."
175146 dap-python--nearest-test))
176147
177148(defun dap-python--template (template-name )
178- (->> dap-debug-template-configurations
179- (-first (-lambda ((name)) (dap-python--equal name template-name)))
180- cdr ))
181-
182- (defun dap-python--debug-test-at-point ()
149+ " Return the debug template whose name is TEMPLATE-NAME.
150+ For the name, only the template's `car' is checked, not its
151+ `:name' property."
152+ (--first (string= template-name it) dap-debug-template-configurations))
153+
154+ (defalias 'dap-python--debug-test-at-point #'dap-python-debug-test-at-point )
155+ (defun dap-python-debug-test-at-point ()
156+ " Debug the pytest test under the cursor."
183157 (interactive )
184158 (dap-debug (dap-python--template " Python :: Run pytest (at point)" )))
185159
0 commit comments