]> git.eshelyaron.com Git - emacs.git/commitdiff
Add tests on electric-indentation and Python multiline strings (Bug#29305)
authorLele Gaifax <lele@metapensiero.it>
Wed, 15 Nov 2017 09:10:19 +0000 (10:10 +0100)
committerNoam Postavsky <npostavs@gmail.com>
Sat, 2 Dec 2017 14:35:44 +0000 (09:35 -0500)
* test/lisp/progmodes/python-tests.el
(python-indent-electric-comma-inside-multiline-string,
python-indent-electric-comma-after-multiline-string): New tests.

test/lisp/progmodes/python-tests.el

index a59885637e9188d7fc78f17d3493e300fb6233c0..010eb67160c5f4206143aab1c41d191e36995a8d 100644 (file)
@@ -1109,6 +1109,37 @@ def fn(a, b, c=True):
    (should (eq (car (python-indent-context)) :inside-string))
    (should (= (python-indent-calculate-indentation) 4))))
 
+(ert-deftest python-indent-electric-comma-inside-multiline-string ()
+  "Test indentation ...."
+  (python-tests-with-temp-buffer
+   "
+a = (
+    '''\
+- foo,
+- bar
+'''
+"
+   (python-tests-look-at "- bar")
+   (should (eq (car (python-indent-context)) :inside-string))
+   (goto-char (line-end-position))
+   (python-tests-self-insert ",")
+   (should (= (current-indentation) 0))))
+
+(ert-deftest python-indent-electric-comma-after-multiline-string ()
+  "Test indentation ...."
+  (python-tests-with-temp-buffer
+   "
+a = (
+    '''\
+- foo,
+- bar'''
+"
+   (python-tests-look-at "- bar'''")
+   (should (eq (car (python-indent-context)) :inside-string))
+   (goto-char (line-end-position))
+   (python-tests-self-insert ",")
+   (should (= (current-indentation) 0))))
+
 (ert-deftest python-indent-electric-colon-1 ()
   "Test indentation case from Bug#18228."
   (python-tests-with-temp-buffer