Skip to content

Commit

Permalink
Ignore inner method names when finding test names.
Browse files Browse the repository at this point in the history
A test name for test runners at most has a class and a single method
name, not any further nested methods.

Fixes #510
  • Loading branch information
jorgenschaefer committed Apr 14, 2015
1 parent 54c4af2 commit 603118e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion elpy.el
Original file line number Diff line number Diff line change
Expand Up @@ -1869,14 +1869,21 @@ directory is not nil."
(let* ((top (elpy-library-root))
(file buffer-file-name)
(module (elpy-test--module-name-for-file top file))
(test (python-info-current-defun)))
(test (elpy-test--current-test-name)))
(if (and file (string-match "/test[^/]*$" file))
(progn
(save-buffer)
(list top file module test))
(save-some-buffers)
(list top nil nil nil)))))

(defun elpy-test--current-test-name ()
(let ((name (python-info-current-defun)))
(if (and name
(string-match "\\`\\([^.]+\\.[^.]+\\)\\." name))
(match-string 1 name)
name)))

(defun elpy-test--module-name-for-file (top-level module-file)
"Return the module name relative to TOP-LEVEL for MODULE-FILE.
Expand Down

0 comments on commit 603118e

Please sign in to comment.