emacs-diffs
[Top][All Lists]
Advanced

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

master 9ad962e 3/4: Expand and improve electric-pair-mode and Python tes


From: João Távora
Subject: master 9ad962e 3/4: Expand and improve electric-pair-mode and Python testing (bug#49518)
Date: Tue, 21 Sep 2021 05:56:49 -0400 (EDT)

branch: master
commit 9ad962e118a17daf073ef5308233f9301755035d
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>

    Expand and improve electric-pair-mode and Python testing (bug#49518)
    
    In python-tests.el, the triple-quote pairing tests are passing
    incorrectly, i.e. the auto-pairing functionality they purport to guard
    isn't really working for users trying it interactively.  Added a new
    failing test, soon to be fixed.
    
    In electric-tests.el, added tests for Python, too.
    
    * test/lisp/electric-tests.el (define-electric-pair-test): Also run
    main tests for python-mode.  (pair-some-quotes-skip-others): Test
    another slightly different pairing.
    
    * test/lisp/progmodes/python-tests.el
    (python-triple-double-quote-pairing): Rename from
    python-triple-quote-pairing.
    (python-triple-single-quote-pairing): New test.
---
 test/lisp/electric-tests.el         |  4 ++--
 test/lisp/progmodes/python-tests.el | 29 ++++++++++++++++++++++++++++-
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/test/lisp/electric-tests.el b/test/lisp/electric-tests.el
index 235f460..46bcbfc 100644
--- a/test/lisp/electric-tests.el
+++ b/test/lisp/electric-tests.el
@@ -174,7 +174,7 @@ The buffer's contents should %s:
           expected-string
           expected-point
           bindings
-          (modes '(quote (ruby-mode js-mode)))
+          (modes '(quote (ruby-mode js-mode python-mode)))
           (test-in-comments t)
           (test-in-strings t)
           (test-in-code t)
@@ -297,7 +297,7 @@ The buffer's contents should %s:
 ;;; Quotes
 ;;;
 (define-electric-pair-test pair-some-quotes-skip-others
-  " \"\"      " "-\"\"-----" :skip-pair-string "-ps------"
+  " \"\"      " "-\"\"-\"---" :skip-pair-string "-ps-p----"
   :test-in-strings nil
   :bindings `((electric-pair-text-syntax-table
                . ,prog-mode-syntax-table)))
diff --git a/test/lisp/progmodes/python-tests.el 
b/test/lisp/progmodes/python-tests.el
index 1af579b..afdae4c 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -5283,7 +5283,7 @@ urlpatterns = patterns('',
            (should (= (current-indentation) 23))))
       (or eim (electric-indent-mode -1)))))
 
-(ert-deftest python-triple-quote-pairing ()
+(ert-deftest python-triple-double-quote-pairing ()
   (let ((epm electric-pair-mode))
     (unwind-protect
         (progn
@@ -5310,6 +5310,33 @@ urlpatterns = patterns('',
                             "\"\n\"\"\"\n"))))
       (or epm (electric-pair-mode -1)))))
 
+(ert-deftest python-triple-single-quote-pairing ()
+  (let ((epm electric-pair-mode))
+    (unwind-protect
+        (progn
+          (python-tests-with-temp-buffer
+           "''\n"
+           (or epm (electric-pair-mode 1))
+           (goto-char (1- (point-max)))
+           (python-tests-self-insert ?')
+           (should (string= (buffer-string)
+                            "''''''\n"))
+           (should (= (point) 4)))
+          (python-tests-with-temp-buffer
+           "\n"
+           (python-tests-self-insert (list ?' ?' ?'))
+           (should (string= (buffer-string)
+                            "''''''\n"))
+           (should (= (point) 4)))
+          (python-tests-with-temp-buffer
+           "'\n''\n"
+           (goto-char (1- (point-max)))
+           (python-tests-self-insert ?')
+           (should (= (point) (1- (point-max))))
+           (should (string= (buffer-string)
+                            "'\n'''\n"))))
+      (or epm (electric-pair-mode -1)))))
+
 
 ;;; Hideshow support
 



reply via email to

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