pytest.el / pytest.el

Diff from to

pytest.el

 ;; In your emacs config:
 ;;
 ;;   (require 'pytest)
-;; 
+;;
 ;; If you don't use a global installation of py.test (ie in
 ;; virtualenv) then add something like the following that points to
 ;; either the non-global version or a test runner script.:
 ;;
 ;;   (add-to-list 'pytest-project-names "my/crazy/runner")
-;; 
+;;
 ;; You can generate a script with py.test:
 ;;
 ;;   py.test --genscript=run-tests.py
 
-;; Another option is if your global pytest isn't called "pytest" is to 
+;; Another option is if your global pytest isn't called "pytest" is to
 ;; redefine pytest-global-name to be the command that should be used.
 
 ;; By default, the root of a project is found by looking for any of the files
 
 (defcustom pytest-cmd-flags "-x"
   "These are the flags passed to the pytest runner")
-  
+
 (defun run-pytest (&optional tests flags)
   "run pytest"
   (virtualenv-hack-dir-local-variables)
   (let* ((pytest (pytest-find-test-runner))
          (where (pytest-find-project-root))
-         (tnames (if tests tests ""))
-	 (cmd-flags (if flags flags pytest-cmd-flags)))
+         (tnames (if tests (mapconcat (lambda (test) (substring test (string-width where)))
+                                      (split-string tests) " ") ""))
+         (cmd-flags (if flags flags pytest-cmd-flags)))
     (funcall '(lambda (command)
-		(compilation-start command nil
-				   (lambda (mode) (concat "*pytest*"))))
-	     (format "cd %s && %s %s %s"
-		     where (pytest-find-test-runner) cmd-flags tnames))))
+                (compilation-start command nil
+                                   (lambda (mode) (concat "*pytest*"))))
+             (format "cd %s && %s %s %s"
+                     where (pytest-find-test-runner) cmd-flags tnames))))
 
 ;;; Run entire test suite
 (defun pytest-all (&optional flags)
 (defun pytest-directory (&optional flags)
   "run pytest on all the files in the current buffer"
   (interactive)
-  (run-pytest (file-name-directory buffer-file-name) flags)) 
+  (run-pytest (file-name-directory buffer-file-name) flags))
 
 (defun pytest-pdb-directory (&optional flags)
   "run pytest on all the files in the current buffer"
   "Run the tests interactively asking for the test flags and
 file/dir"
   (interactive)
-  (let ((tests (expand-file-name 
-		(read-file-name "Test directory or file: "
-				(pytest-current-root))))
-	(flags (read-from-minibuffer "py.test flags: ")))
+  (let ((tests (expand-file-name
+                (read-file-name "Test directory or file: "
+                                (pytest-current-root))))
+        (flags (read-from-minibuffer "py.test flags: ")))
     (run-pytest tests flags)))
 
 
 ;;; Utility functions
 (defun pytest-find-test-runner ()
   (let ((result
-	 (reduce '(lambda (x y) (or x y))
-		 (mapcar 'pytest-find-test-runner-names pytest-project-names))))
+         (reduce '(lambda (x y) (or x y))
+                 (mapcar 'pytest-find-test-runner-names pytest-project-names))))
     (if result
-	result
+        result
       pytest-global-name)))
 
 (defun pytest-find-test-runner-names (runner)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.