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

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

[elpa] externals/eglot dbb5dd4 57/69: Slightly more robust completion te


From: João Távora
Subject: [elpa] externals/eglot dbb5dd4 57/69: Slightly more robust completion tests
Date: Sun, 20 Oct 2019 08:21:53 -0400 (EDT)

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

    Slightly more robust completion tests
    
    Give snippet-related tests a change of passing by ensuring pyls
    produces snippets. It doesn't do taht anymore by default, so we
    explicitly configure its jedi_completion pluging to do so, using
    eglot-workspace-configuration.
    
    * eglot-tests.el (company): Require it, but don't fail.
    (eglot--test-python-buffer): New helper var.
    (snippet-completions): Improve test.
    (snippet-completions-with-company): New test.
    (company-candidates): Shoosh a warning.
---
 eglot-tests.el | 42 +++++++++++++++++++++++++++++++++++++++---
 1 file changed, 39 insertions(+), 3 deletions(-)

diff --git a/eglot-tests.el b/eglot-tests.el
index 2d9f783..5984816 100644
--- a/eglot-tests.el
+++ b/eglot-tests.el
@@ -29,6 +29,7 @@
 (require 'ert-x) ; ert-simulate-command
 (require 'edebug)
 (require 'python) ; python-mode-hook
+(require 'company nil t)
 
 ;; Helpers
 
@@ -461,19 +462,54 @@ Pass TIMEOUT to `eglot--with-timeout'."
       (call-interactively 'xref-find-definitions)
       (should (looking-at "foo(): pass")))))
 
+(defvar eglot--test-python-buffer
+  "\
+def foobarquux(a, b, c=True): pass
+def foobazquuz(d, e, f): pass
+")
+
 (ert-deftest snippet-completions ()
   "Test simple snippet completion in a python LSP"
   (skip-unless (and (executable-find "pyls")
                     (functionp 'yas-minor-mode)))
   (eglot--with-fixture
-      '(("project" . (("something.py" . "setatt"))))
+      `(("project" . (("something.py" . ,eglot--test-python-buffer))))
     (with-current-buffer
         (eglot--find-file-noselect "project/something.py")
       (yas-minor-mode 1)
-      (should (eglot--tests-connect))
+      (let ((eglot-workspace-configuration
+             `((:pyls . (:plugins (:jedi_completion (:include_params t)))))))
+        (should (eglot--tests-connect)))
       (goto-char (point-max))
+      (insert "foobar")
       (completion-at-point)
-      (should (looking-back "setattr(")))))
+      (beginning-of-line)
+      (should (looking-at "foobarquux(a, b)")))))
+
+(defvar company-candidates)
+
+(ert-deftest snippet-completions-with-company ()
+  "Test simple snippet completion in a python LSP"
+  (skip-unless (and (executable-find "pyls")
+                    (functionp 'yas-minor-mode)
+                    (functionp 'company-complete)))
+  (eglot--with-fixture
+      `(("project" . (("something.py" . ,eglot--test-python-buffer))))
+    (with-current-buffer
+        (eglot--find-file-noselect "project/something.py")
+      (yas-minor-mode 1)
+      (let ((eglot-workspace-configuration
+             `((:pyls . (:plugins (:jedi_completion (:include_params t)))))))
+        (should (eglot--tests-connect)))
+      (goto-char (point-max))
+      (insert "foo")
+      (company-mode)
+      (company-complete)
+      (should (looking-back "fooba"))
+      (should (= 2 (length company-candidates)))
+      ;; this last one is brittle, since there it is possible that
+      ;; pyls will change the representation of this candidate
+      (should (member "foobazquuz(d, e, f)" company-candidates)))))
 
 (ert-deftest hover-after-completions ()
   "Test documentation echo in a python LSP"



reply via email to

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