emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/eglot 40a3d8c 16/69: Fix broken python formatting tests


From: João Távora
Subject: [elpa] externals/eglot 40a3d8c 16/69: Fix broken python formatting tests
Date: Sun, 20 Oct 2019 08:21:44 -0400 (EDT)

branch: externals/eglot
commit 40a3d8cbe837a10b3024d6fe6fcfe1fbda12c3d6
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>

    Fix broken python formatting tests
    
    * eglot-tests.el (formatting): Split test.
    (python-autopep-formatting, python-yapf-formatting): New tests.
---
 eglot-tests.el | 43 +++++++++++++++++++++++++++++--------------
 1 file changed, 29 insertions(+), 14 deletions(-)

diff --git a/eglot-tests.el b/eglot-tests.el
index 8a9aba6..d1f56db 100644
--- a/eglot-tests.el
+++ b/eglot-tests.el
@@ -447,32 +447,47 @@ Pass TIMEOUT to `eglot--with-timeout'."
       (while (not eldoc-last-message) (accept-process-output nil 0.1))
       (should (string-match "^exit" eldoc-last-message)))))
 
-(ert-deftest formatting ()
-  "Test formatting in a python LSP"
+(ert-deftest python-autopep-formatting ()
+  "Test formatting in the pyls python LSP.
+pyls prefers autopep over yafp"
   (skip-unless (and (executable-find "pyls")
-                    (or (executable-find "yapf")
-                        (executable-find "autopep8"))))
+                    (executable-find "autopep8")))
   (eglot--with-fixture
       '(("project" . (("something.py" . "def a():pass\ndef b():pass"))))
     (with-current-buffer
         (eglot--find-file-noselect "project/something.py")
       (should (eglot--tests-connect))
+      ;; Try to format just the second line
       (search-forward "b():pa")
       (eglot-format (point-at-bol) (point-at-eol))
       (should (looking-at "ss"))
       (should
-       (or
-        ;; yapf
-        (string= (buffer-string) "def a():pass\n\n\ndef b():\n    pass\n")
-        ;; autopep8
-        (string= (buffer-string) "def a():pass\n\n\ndef b(): pass\n")))
+       (string= (buffer-string) "def a():pass\n\n\ndef b(): pass\n"))
+      ;; now format the whole buffer
       (eglot-format-buffer)
       (should
-       (or
-        ;; yapf
-        (string= (buffer-string) "def a():\n    pass\n\n\ndef b():\n    
pass\n")
-        ;; autopep8
-        (string= (buffer-string) "def a(): pass\n\n\ndef b(): pass\n"))))))
+       (string= (buffer-string) "def a(): pass\n\n\ndef b(): pass\n")))))
+
+(ert-deftest python-yapf-formatting ()
+  "Test formatting in the pyls python LSP"
+  (skip-unless (and (executable-find "pyls")
+                    (not (executable-find "autopep8"))
+                    (executable-find "yapf")))
+  (eglot--with-fixture
+      '(("project" . (("something.py" . "def a():pass\ndef b():pass"))))
+    (with-current-buffer
+        (eglot--find-file-noselect "project/something.py")
+      (should (eglot--tests-connect))
+      ;; Try to format just the second line
+      (search-forward "b():pa")
+      (eglot-format (point-at-bol) (point-at-eol))
+      (should (looking-at "ss"))
+      (should
+       (string= (buffer-string) "def a():pass\n\n\ndef b():\n    pass\n"))
+      ;; now format the whole buffer
+      (eglot-format-buffer)
+      (should
+       (string= (buffer-string) "def a():\n    pass\n\n\ndef b():\n    
pass\n")))))
 
 (ert-deftest javascript-basic ()
   "Test basic autocompletion in a python LSP"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]