Running py.test from emacs

What would I like if Cc Cc runs py.test and displays the output in another buffer, if the name of the file being edited starts with test_ and usually runs py-execute-buffer. How can I do it? I am using emacs 23.1.1 with python-mode and can access py.test from the command line.

+7
python emacs
source share
1 answer

This is not particularly well verified; it's just a gross idea.

(defun py-do-it () (interactive) (if (string-match (rx bos "test_") (file-name-nondirectory (buffer-file-name))) (compile "py.test") (py-execute-buffer))) (add-hook 'python-mode-hook (lambda () (local-set-key (kbd "F5") ;or whatever 'py-do-it))) 
+7
source share

All Articles