From 81ec639b70ccfd36594021bf93d4959a83730185 Mon Sep 17 00:00:00 2001 From: Ohad Livne Date: Wed, 4 Jun 2025 22:47:12 +0300 Subject: [PATCH] Remove LSP-based Python test functions --- .config/emacs/init.el | 41 +---------------------------------------- 1 file changed, 1 insertion(+), 40 deletions(-) diff --git a/.config/emacs/init.el b/.config/emacs/init.el index 010e704..855d720 100644 --- a/.config/emacs/init.el +++ b/.config/emacs/init.el @@ -240,49 +240,10 @@ (poetry-venv-workon) (lsp))) -(defun symbols-at-point () - "Utility function to get the hierarchy of the object at point." - (let* ((lsp--document-symbols-request-async t) - (symbols (lsp--get-document-symbols)) - (symbols-hierarchy (lsp--symbols->document-symbols-hierarchy symbols))) - (mapcar (lambda (symb) - (list (gethash "name" symb) (lsp--get-symbol-type symb))) - symbols-hierarchy))) - -(defun python-test-at-point () - "Use LSP to identify the test at point." - (let ((symbols (symbols-at-point))) - (pcase symbols - (`((,class "Class") (,method "Method") . ,_) - (if (equal "test_" (substring method 0 5)) - `(,class ,method) - `(,class))) - (`((,class "Class") . ,_) `(,class)) - (_ ())))) - -(defun python-test-name-at-point () - "Create a unittest-compatible descriptor for the test at point." - (let* ((path (mapcar #'substring-no-properties lsp-headerline--path-up-to-project-segments)) - (filename (f-no-ext (f-filename (buffer-file-name))))) - (string-join (append path (list filename) (python-test-at-point)) "."))) - -(defun python-run-test-at-point (debug) - "Identify and run the test at point. -When DEBUG is set, run the test in the debugger." - (interactive "P") - (let ((python (or (executable-find "python3") - (executable-find "python"))) - (test-name (python-test-name-at-point))) - (if debug - (pdb (concat python " -m pdb -m unittest " test-name)) - (compile (concat python " -m unittest " test-name))))) - (use-package python :bind (:map python-mode-map ("C-c C-p" . nil) - ("C-c C-l" . nil) - ("C-c C-t" . python-run-test-at-point) - ("C-M-t" . recompile)) + ("C-c C-l" . nil)) :hook (python-mode . load-python-env)) ;; Jupyter notebook integration