aboutsummaryrefslogtreecommitdiffstats
path: root/test/lisp/progmodes/python-tests.el
diff options
context:
space:
mode:
authorDmitry Gutov2023-03-08 22:41:23 +0200
committerDmitry Gutov2023-03-08 22:48:33 +0200
commit34c14430e9d070ffc98527fc95677dd5c5758536 (patch)
tree3c85789c30e85ffdb324c46378d5c3151f270c95 /test/lisp/progmodes/python-tests.el
parent8a2a554192a936257e88f12b4dfbd4f923d135f3 (diff)
downloademacs-34c14430e9d070ffc98527fc95677dd5c5758536.tar.gz
emacs-34c14430e9d070ffc98527fc95677dd5c5758536.zip
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/lisp/progmodes/python-tests.el')
-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:
1982 (should (eq (car (python-indent-context)) :after-block-start)) 1982 (should (eq (car (python-indent-context)) :after-block-start))
1983 (should (= (python-indent-calculate-indentation) 8)))) 1983 (should (= (python-indent-calculate-indentation) 8))))
1984 1984
1985(ert-deftest python-indent-after-re-match ()
1986 "Test BUG 62031 regression."
1987 (python-tests-with-temp-buffer
1988 "
1989def test_re(string):
1990 if re.match('^[a-c]+$', string):
1991 print('yes')
1992 else:
1993 "
1994 (python-tests-look-at "else:")
1995 (should (= (python-indent-calculate-indentation) 4))))
1996
1985 1997
1986;;; Filling 1998;;; Filling
1987 1999