            tox-default-env))
         (default-directory (tox-get-root-directory))
         (compilation-auto-jump-to-first-error nil)
-        (compilation-scroll-output nil))
-    (compile (tox-get-command toxenvs)))
+        (compilation-scroll-output nil)
+        (current-function (python-info-current-defun)))
+    (unless current-function
+      (error "No function at point"))
+    (compile (tox-get-command current-function toxenvs)))
   )
 
 ;;; End tox.el ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

                      (buffer-file-name) "tox.ini")
                     "./")))

(defun tox-get-command (&optional envlist)
  "Return the command to launch tests."
  (let ((current-function (python-info-current-defun)))
    (unless current-function
      (error "No function at point"))
    (concat
     tox-program " "
     tox-arg " "

                   (buffer-file-name))
                  (length (tox-get-root-directory)))))
     ":"
     tox-test))

;;; Public interface ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

