aboutsummaryrefslogtreecommitdiffstats
path: root/test/lisp/progmodes/python-tests.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen2022-07-27 11:38:19 +0200
committerLars Ingebrigtsen2022-07-27 11:38:19 +0200
commit8be5481b8ed869e1ac04c07c3919a9a49afd8667 (patch)
tree2e23c31a5961c0f90668bd924a61b7734e98b091 /test/lisp/progmodes/python-tests.el
parentdc84264f3cb2ea9ab5b0af9f3529ebddb6bc0219 (diff)
downloademacs-8be5481b8ed869e1ac04c07c3919a9a49afd8667.tar.gz
emacs-8be5481b8ed869e1ac04c07c3919a9a49afd8667.zip
Add a test for python-mode comment/else problem
Based on a patch from kobarity <kobarity@gmail.com>
Diffstat (limited to 'test/lisp/progmodes/python-tests.el')
-rw-r--r--test/lisp/progmodes/python-tests.el29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
index 3b10bde23bc..6f2ad87f81a 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -1122,6 +1122,35 @@ if save:
1122 (python-indent-line t) 1122 (python-indent-line t)
1123 (should (= (python-indent-calculate-indentation t) 8)))) 1123 (should (= (python-indent-calculate-indentation t) 8))))
1124 1124
1125(ert-deftest python-indent-dedenters-comment-else ()
1126 "Test de-indentation for the else keyword with comments before it."
1127 (python-tests-with-temp-buffer
1128 "
1129if save:
1130 try:
1131 write_to_disk(data)
1132 except IOError:
1133 msg = 'Error saving to disk'
1134 message(msg)
1135 logger.exception(msg)
1136 except Exception:
1137 if hide_details:
1138 logger.exception('Unhandled exception')
1139 # comment
1140 else
1141 finally:
1142 data.free()
1143"
1144 (python-tests-look-at "else\n")
1145 (should (eq (car (python-indent-context)) :at-dedenter-block-start))
1146 (should (= (python-indent-calculate-indentation) 8))
1147 (python-indent-line t)
1148 (should (= (python-indent-calculate-indentation t) 4))
1149 (python-indent-line t)
1150 (should (= (python-indent-calculate-indentation t) 0))
1151 (python-indent-line t)
1152 (should (= (python-indent-calculate-indentation t) 8))))
1153
1125(ert-deftest python-indent-dedenters-3 () 1154(ert-deftest python-indent-dedenters-3 ()
1126 "Test de-indentation for the except keyword." 1155 "Test de-indentation for the except keyword."
1127 (python-tests-with-temp-buffer 1156 (python-tests-with-temp-buffer