diff elpa/elpy-1.26.0/elpy-django.el @ 183:3de719fb264a

elpy: version 1.26
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Wed, 21 Nov 2018 14:39:16 -0500
parents elpa/elpy-1.25.0/elpy-django.el@c3bd84985977
children
line wrap: on
line diff
copy from elpa/elpy-1.25.0/elpy-django.el
copy to elpa/elpy-1.26.0/elpy-django.el
--- a/elpa/elpy-1.25.0/elpy-django.el
+++ b/elpa/elpy-1.26.0/elpy-django.el
@@ -79,9 +79,11 @@
 (make-variable-buffer-local 'elpy-django-commands-with-req-arg)
 
 (defcustom elpy-django-test-runner-formats '(("django_nose.NoseTestSuiteRunner" . ":")
-                                             ("django.test.runner.DiscoverRunner" . "."))
+                                             (".*" . "."))
   "List of test runners and their format for calling tests.
 
+  The keys are the regular expressions to match the runner used in test, 
+while the values are the separators to use to build test target path.
 Some tests runners are called differently. For example, Nose requires a ':' when calling specific tests,
 but the default Django test runner uses '.'"
   :type 'list
@@ -191,11 +193,17 @@
 (defun elpy-django--get-test-format ()
   "When running a Django test, some test runners require a different format that others.
 Return the correct string format here."
-  (let  ((pair (assoc (elpy-django--get-test-runner) elpy-django-test-runner-formats)))
-    (if pair
-        ;; Return the associated test format
-        (cdr pair)
-      (error (format "Unable to find test format for `%s'" (elpy--get-django-test-runner))))))
+  (let ((runner (elpy-django--get-test-runner))
+        (found nil)
+        (formats elpy-django-test-runner-formats))
+    (while (and formats (not found))
+      (let* ((entry (car formats)) (regex (car entry)))
+        (when (string-match regex runner)
+          (setq found (cdr entry))))
+      (setq formats (cdr formats)))
+    (or found (error (format "Unable to find test format for `%s'"
+                             (elpy-django--get-test-runner))))))
+
 
 ;;;;;;;;;;;;;;;;;;;;;;
 ;;; User Functions