Add nosetests integration

This commit is contained in:
Jeremy Dormitzer 2020-02-14 12:38:18 -05:00
parent 0a1f1f6060
commit ab5d635cc4

View File

@ -2566,7 +2566,7 @@ And support pyenv (NOT pyvenv) to change Python versions:
(append autoflake-args (list "--in-place" file)))))
#+END_SRC
** Pytest
** Testing
[[https://github.com/wbolster/emacs-python-pytest][python-pytest.el]] integrates Pytest with Emacs:
#+BEGIN_SRC emacs-lisp
(use-package python-pytest
@ -2575,6 +2575,79 @@ And support pyenv (NOT pyvenv) to change Python versions:
(python-mode-map "C-c t p" #'python-pytest-popup))
#+END_SRC
And borrowing some functions from python-pytest, we can get some nosetests support as well:
#+BEGIN_SRC emacs-lisp
(defvar nosetests-args ""
"Additional args to pass to nosetests")
(defun run-nose (args)
"Runs nosetests with `args'"
(let ((nosetests-cmd (executable-find "nosetests")))
(when (not nosetests-cmd)
(user-error "Nosetests command not found"))
(compile (format "%s %s" nosetests-cmd args) t)))
(defun run-nose-reading-args (arg nose-args)
"Runs nosetests with default args
or prompts for args with prefix"
(let ((args (if arg
(read-string "Nosetests arguments: "
nil nil nosetests-args)
nosetests-args)))
(run-nose (format "%s %s" args nose-args))))
(defun run-nose-in-project (arg nose-args)
"Runs nosetests from the project root"
(let ((dir (or (projectile-project-root)
default-directory)))
(with-temp-buffer
(cd dir)
(run-nose-reading-args arg nose-args))))
(defun nosetests-all (arg)
"Runs nosetests on all project tests, prompting for the tests directory"
(interactive "P")
(let ((test-dir (read-file-name "Test directory: "
(or (projectile-project-root)
default-directory)
nil t "tests" #'directory-name-p)))
(run-nose-in-project arg (directory-file-name test-dir))))
(defun nosetests-module (arg module)
"Runs nosetests in the module of the current file"
(interactive (list current-prefix-arg
(read-file-name "Run nosetests on module: "
nil nil t
(file-name-directory
(buffer-file-name))
#'directory-name-p)))
(run-nose-in-project arg (directory-file-name module)))
(defun nosetests-file (arg file)
"Runs nosetests on the current file"
(interactive (list current-prefix-arg
(read-file-name "Run nosetests on file: "
nil nil t (buffer-file-name))))
(run-nose-in-project arg file))
(defun nosetests-def (arg def)
"Runs nosetests on the enclosing function at point"
(interactive (list current-prefix-arg
(python-pytest--current-defun)))
(run-nose-in-project arg (format "%s:%s"
(buffer-file-name)
def)))
(defvar nosetests-map (make-sparse-keymap)
"Keymap for nosetests")
(general-def python-mode-map "C-c t n" nosetests-map)
(general-def nosetests-map "a" #'nosetests-all)
(general-def nosetests-map "m" #'nosetests-module)
(general-def nosetests-map "f" #'nosetests-file)
(general-def nosetests-map "d" #'nosetests-def)
#+END_SRC
* Hy
Python but Lispy!
@ -5187,6 +5260,12 @@ Enable ANSI colors in compile buffers:
(add-hook 'compilation-filter-hook #'colorize-compilation-buffer)
#+END_SRC
Ensure the "q" will quit-window even in Comint-mode compilation buffers:
#+BEGIN_SRC emacs-lisp
(general-def (normal visual motion) compilation-shell-minor-mode-map "q" #'quit-window)
#+END_SRC
* Wallabag
[[https://github.com/jdormit/emacs-wallabag-client][My Wallabag client]] is still a WIP, but it is useful enough to pull in right now:
#+BEGIN_SRC emacs-lisp