diff --git a/emacs/.emacs.d/config/init-run-command.el b/emacs/.emacs.d/config/init-run-command.el index 621ba2d..f2e06f2 100644 --- a/emacs/.emacs.d/config/init-run-command.el +++ b/emacs/.emacs.d/config/init-run-command.el @@ -176,6 +176,26 @@ "::" (python-info-current-defun))))))))) + (defun run-command-recipe-nosetests() + (when (and (derived-mode-p 'python-mode) + (= 0 (call-process "python" nil nil nil "-c" "import nose"))) + (let ((test-file-p (string-match-p "test" (or (buffer-file-name) "")))) + (list + (when (and (projectile-project-root) + (file-exists-p (concat (file-name-as-directory (projectile-project-root)) + "tests"))) + (list :command-name "test all" + :command-line "nosetests -w tests" + :working-dir (projectile-project-root))) + (when test-file-p + (list :command-name "test this file" + :command-line (format "nosetests %s" (buffer-file-name)))) + (when (and test-file-p (python-info-current-defun)) + (list :command-name "test this function" + :command-line (format "nosetests %s:%s" + (buffer-file-name) + (python-info-current-defun)))))))) + (defun run-command-recipe-web-ext () (when-let* ((_ (executable-find "web-ext")) (manifest (locate-dominating-file default-directory "manifest.json")) @@ -210,6 +230,7 @@ run-command-recipe-kustomize run-command-recipe-sops run-command-recipe-pytest + run-command-recipe-nosetests run-command-recipe-web-ext run-command-recipe-pip)))