]> git.eshelyaron.com Git - emacs.git/commitdiff
Expand and improve electric-pair-mode and Python testing (bug#49518)
authorJoão Távora <joaotavora@gmail.com>
Sun, 19 Sep 2021 16:08:41 +0000 (17:08 +0100)
committerJoão Távora <joaotavora@gmail.com>
Tue, 21 Sep 2021 09:54:19 +0000 (10:54 +0100)
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
test/lisp/progmodes/python-tests.el

index 235f46056fa5c6313776ffedce1475ad9dac8f0a..46bcbfce30776df429c3b8a247d55db081ec6204 100644 (file)
@@ -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)))
index 1af579bb7a47ca710dc04daee2d1284e5b5e2a95..afdae4c75c6f4d10bd4e5f81fc91439a552e0e2a 100644 (file)
@@ -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)))))
+
 \f
 ;;; Hideshow support