(should (= (point) (point-min)))))
(ert-deftest python-triple-quote-pairing ()
- (python-tests-with-temp-buffer
- "\"\"\n"
- (goto-char (1- (point-max)))
- (let ((last-command-event ?\"))
- (call-interactively 'self-insert-command))
- (should (string= (buffer-string)
- "\"\"\"\"\"\"\n"))
- (should (= (point) 4)))
- (python-tests-with-temp-buffer
- "\n"
- (let ((last-command-event ?\"))
- (dotimes (i 3)
- (call-interactively 'self-insert-command)))
- (should (string= (buffer-string)
- "\"\"\"\"\"\"\n"))
- (should (= (point) 4)))
- (python-tests-with-temp-buffer
- "\"\n\"\"\n"
- (goto-char (1- (point-max)))
- (let ((last-command-event ?\"))
- (call-interactively 'self-insert-command))
- (should (= (point) (1- (point-max))))
- (should (string= (buffer-string)
- "\"\n\"\"\"\n"))))
+ (require 'electric)
+ (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)))
+ (let ((last-command-event ?\"))
+ (call-interactively 'self-insert-command))
+ (should (string= (buffer-string)
+ "\"\"\"\"\"\"\n"))
+ (should (= (point) 4)))
+ (python-tests-with-temp-buffer
+ "\n"
+ (let ((last-command-event ?\"))
+ (dotimes (i 3)
+ (call-interactively 'self-insert-command)))
+ (should (string= (buffer-string)
+ "\"\"\"\"\"\"\n"))
+ (should (= (point) 4)))
+ (python-tests-with-temp-buffer
+ "\"\n\"\"\n"
+ (goto-char (1- (point-max)))
+ (let ((last-command-event ?\"))
+ (call-interactively 'self-insert-command))
+ (should (= (point) (1- (point-max))))
+ (should (string= (buffer-string)
+ "\"\n\"\"\"\n"))))
+ (or epm (electric-pair-mode -1)))))
(provide 'python-tests)