Last active
December 11, 2017 06:27
-
-
Save TauPan/17305751a883005872dc to your computer and use it in GitHub Desktop.
Emacs configuration snippet for testing python with elpy, nosetests and django-nose with pdb in a gud-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
(use-package elpy | |
:config | |
(progn (elpy-enable) | |
(defun elpy-nose-test-spec (module test) | |
(cond (test | |
(format "%s:%s" module test)) | |
(module module) | |
(t ""))) | |
(defun elpy-test-nose-pdb-runner (top file module test) | |
"Test the project using the nose test runner with the --pdb arg. | |
This requires the nose package to be installed." | |
(interactive (elpy-test-at-point)) | |
(let ((default-directory top)) | |
(pdb (format "nosetests --pdb %s" | |
(elpy-nose-test-spec module test))))) | |
(put 'elpy-test-nose-pdb-runner 'elpy-test-runner-p t) | |
(defvar elpy-test-pdb-runner | |
#'elpy-test-nose-pdb-runner | |
"Test runner to run with pdb") | |
(defun elpy-test-django-nose-pdb-runner (top file module test) | |
"Test the project using the django-nose test runner with the --pdb arg. | |
This requires the django-nose package to be installed and | |
properly configured for the django project." | |
(interactive (elpy-test-at-point)) | |
(let ((default-directory top)) | |
(pdb (format "django-admin.py test --noinput %s --pdb" | |
(elpy-nose-test-spec module test))))) | |
(defun elpy-test-pdb (&optional test-whole-project) | |
"Run test the current project with the elpy-test-pdb-runner | |
prefix args have the same semantics as for `elpy-test'" | |
(interactive "P") | |
(let ((elpy-test-runner elpy-test-pdb-runner)) | |
(elpy-test test-whole-project))) | |
(eval-after-load 'elpy | |
'(progn | |
(define-key elpy-mode-map | |
(kbd "C-c t") 'elpy-test-pdb))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment