1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-05 11:45:45 +00:00

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.
This commit is contained in:
João Távora 2021-09-19 17:08:41 +01:00
parent f57ef81031
commit 9ad962e118
2 changed files with 30 additions and 3 deletions

View 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)))

View 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)))))
;;; Hideshow support