summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDmitry Gutov <dgutov@yandex.ru>2023-03-08 22:41:23 +0200
committerDmitry Gutov <dgutov@yandex.ru>2023-03-08 22:48:33 +0200
commit34c14430e9d070ffc98527fc95677dd5c5758536 (patch)
tree3c85789c30e85ffdb324c46378d5c3151f270c95 /test
parent8a2a554192a936257e88f12b4dfbd4f923d135f3 (diff)
downloademacs-34c14430e9d070ffc98527fc95677dd5c5758536.tar.gz
Don't misindent 'else:' after 'if re.match:' in Python
* lisp/progmodes/python.el (python-info-dedenter-opening-block-positions): Check that the supposed block start is not a method call (bug#62031). * test/lisp/progmodes/python-tests.el (python-indent-after-re-match): New test. Co-authored-by: Lele Gaifax <lele@metapensiero.it>
Diffstat (limited to 'test')
-rw-r--r--test/lisp/progmodes/python-tests.el12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
index 4f24c042c6a..6928e313dc4 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -1982,6 +1982,18 @@ match foo:
(should (eq (car (python-indent-context)) :after-block-start))
(should (= (python-indent-calculate-indentation) 8))))
+(ert-deftest python-indent-after-re-match ()
+ "Test BUG 62031 regression."
+ (python-tests-with-temp-buffer
+ "
+def test_re(string):
+ if re.match('^[a-c]+$', string):
+ print('yes')
+ else:
+ "
+ (python-tests-look-at "else:")
+ (should (= (python-indent-calculate-indentation) 4))))
+
;;; Filling