Remove LSP-based Python test functions
This commit is contained in:
parent
87b86d71b9
commit
81ec639b70
1 changed files with 1 additions and 40 deletions
|
|
@ -240,49 +240,10 @@
|
||||||
(poetry-venv-workon)
|
(poetry-venv-workon)
|
||||||
(lsp)))
|
(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
|
(use-package python
|
||||||
:bind (:map python-mode-map
|
:bind (:map python-mode-map
|
||||||
("C-c C-p" . nil)
|
("C-c C-p" . nil)
|
||||||
("C-c C-l" . nil)
|
("C-c C-l" . nil))
|
||||||
("C-c C-t" . python-run-test-at-point)
|
|
||||||
("C-M-t" . recompile))
|
|
||||||
:hook (python-mode . load-python-env))
|
:hook (python-mode . load-python-env))
|
||||||
|
|
||||||
;; Jupyter notebook integration
|
;; Jupyter notebook integration
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue