summaryrefslogtreecommitdiff
path: root/test/lisp
diff options
context:
space:
mode:
authorJoão Távora <joaotavora@gmail.com>2021-09-19 17:08:41 +0100
committerJoão Távora <joaotavora@gmail.com>2021-09-21 10:54:19 +0100
commit9ad962e118a17daf073ef5308233f9301755035d (patch)
tree0ee7ec3e5e3c144d3ba45f1459fac696fc7190d5 /test/lisp
parentf57ef8103139193f48d6c668212e17e476ed1678 (diff)
downloademacs-9ad962e118a17daf073ef5308233f9301755035d.tar.gz
emacs-9ad962e118a17daf073ef5308233f9301755035d.tar.bz2
emacs-9ad962e118a17daf073ef5308233f9301755035d.zip
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.
Diffstat (limited to 'test/lisp')
-rw-r--r--test/lisp/electric-tests.el4
-rw-r--r--test/lisp/progmodes/python-tests.el29
2 files changed, 30 insertions, 3 deletions
diff --git a/test/lisp/electric-tests.el b/test/lisp/electric-tests.el
index 235f46056fa..46bcbfce307 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 1af579bb7a4..afdae4c75c6 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