dap-mode
dap-mode copied to clipboard
python-test-at-point fails with wrong-type-argument hash-table-p nil
I am facing an issue similar to #396. dap-debug
template 'Run pytest (at point)' fails with wrong-type-argument hash-table-p nil
.
emacs 28.0.50 dap-mode-20210506.1934 lsp-mode-20210508.628
Backtrace:
Debugger entered--Lisp error: (wrong-type-argument hash-table-p nil)
dap-python--parse-lsp-symbol(#<hash-table equal 4/4 0x15889706cd4f>)
dap-python--test-at-point()
#<subr dap-python--populate-test-at-point>((:type "python-test-at-point" :args "" :program nil :module "pytest" :request "launch" :name "Python :: Run pytest (at point)"))
apply(#<subr dap-python--populate-test-at-point> (:type "python-test-at-point" :args "" :program nil :module "pytest" :request "launch" :name "Python :: Run pytest (at point)"))
#f(compiled-function (body &rest args) #<bytecode -0x60daa5069e3b293>)(#<subr dap-python--populate-test-at-point> (:type "python-test-at-point" :args "" :program nil :module "pytest" :request "launch" :name "Python :: Run pytest (at point)"))
apply(#f(compiled-function (body &rest args) #<bytecode -0x60daa5069e3b293>) #<subr dap-python--populate-test-at-point> (:type "python-test-at-point" :args "" :program nil :module "pytest" :request "launch" :name "Python :: Run pytest (at point)"))
dap-python--populate-test-at-point((:type "python-test-at-point" :args "" :program nil :module "pytest" :request "launch" :name "Python :: Run pytest (at point)"))
dap-debug((:type "python-test-at-point" :args "" :program nil :module "pytest" :request "launch" :name "Python :: Run pytest (at point)"))
funcall-interactively(dap-debug (:type "python-test-at-point" :args "" :program nil :module "pytest" :request "launch" :name "Python :: Run pytest (at point)"))
command-execute(dap-debug record)
I could solve it by modifying the way 'python-test-at-point
finds the current test. I am using the function of my test-cockpit.el
package.
(defun dap-python-johmue-populate-test-at-point (conf)
"Populate CONF with the required arguments."
(if-let ((test (test-cockpit--python--test-function-path)))
(plist-put conf :program test)
(user-error "`dap-python': no test at point"))
(plist-put conf :cwd (lsp-workspace-root))
(dap-python--populate-start-file-args conf))
(dap-register-debug-provider "python-test-at-point" 'dap-python-johmue-populate-test-at-point)
(dap-register-debug-template "Python :: Run pytest (at point)"
(list :type "python-test-at-point"
:args ""
:program nil
:module "pytest"
:request "launch"
:name "Python :: Run pytest (at point)"))
I am leaving the issue open, as it is not actually fixed in dap-mode
.