Last active
April 28, 2017 17:25
-
-
Save abingham/8377114eec25d8578cf0 to your computer and use it in GitHub Desktop.
Emacs routine for running python tests and displaying the results in a buffer.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun run-python-tests (root-dir test-subdir buffer-name) | |
(interactive) | |
(let ((default-directory root-dir) | |
(buff (get-buffer-create buffer-name))) | |
(display-buffer buff) | |
(shell-command (concat "python -m unittest discover " test-subdir) buff) | |
(with-current-buffer buff | |
(compilation-mode)))) | |
; This hook runs the tests after each save, a TDD-esque workflow. | |
(add-hook 'after-save-hook | |
(lambda () (run-python-tests "~/projects/project_name/" | |
"project_name/test" | |
"*python-tests*"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment