diff options
| author | Paul Eggert | 2015-02-25 22:53:56 -0800 |
|---|---|---|
| committer | Paul Eggert | 2015-02-25 22:53:56 -0800 |
| commit | d8e9122115b5ffcec342c841b81cb2d2b8217e4b (patch) | |
| tree | 477830be0a1707699381146a4ed45c53d0b928b0 /test/automated/python-tests.el | |
| parent | cbd447e1cdbbebcd2a04144194138bb7936dea9d (diff) | |
| parent | e726f2058c98e68c951bdb290fe68dac2a84ff65 (diff) | |
| download | emacs-d8e9122115b5ffcec342c841b81cb2d2b8217e4b.tar.gz emacs-d8e9122115b5ffcec342c841b81cb2d2b8217e4b.zip | |
Merge from origin/emacs-24
e726f20 Handle "#" operator properly inside macro. Fix coding bug.
618931b Handle dead frame in menu-bar-non-minibuffer-window-p. (Bug#19728)
017a03a Document MS-Windows file-name idiosyncrasies (Bug#19463)
f3faf4f Fix description of Customize buffer in Emacs manual.
1c1d0b7 Fix a typo in the Emacs manual's Hungry Delete description.
be7fb82 src/dispextern.h (FACE_FOR_CHAR): Fix the commentary.
33c4409 Spelling fixes
6c8231e python.el: Handle tabs in python-indent-dedent-line.
41c3b92 * lisp/progmodes/python.el: Respect user indentation after comment.
868df45 Avoid compiler warnings in decode_env_path.
b28c979 Fix XEmacs version typo in comment and ChangeLog
989fb32 Improve solution of bug #19701
6310530 Fix refilling of list of language environments in User Manual
c4c447d Restore XEmacs compatibility
Conflicts:
doc/emacs/ChangeLog
lisp/ChangeLog
src/ChangeLog
test/ChangeLog
Diffstat (limited to 'test/automated/python-tests.el')
| -rw-r--r-- | test/automated/python-tests.el | 104 |
1 files changed, 87 insertions, 17 deletions
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el index 47e2a6e8195..b377a26f77a 100644 --- a/test/automated/python-tests.el +++ b/test/automated/python-tests.el | |||
| @@ -204,7 +204,7 @@ foo = long_function_name(var_one, var_two, | |||
| 204 | (should (eq (car (python-indent-context)) :no-indent)) | 204 | (should (eq (car (python-indent-context)) :no-indent)) |
| 205 | (should (= (python-indent-calculate-indentation) 0)) | 205 | (should (= (python-indent-calculate-indentation) 0)) |
| 206 | (python-tests-look-at "foo = long_function_name(var_one, var_two,") | 206 | (python-tests-look-at "foo = long_function_name(var_one, var_two,") |
| 207 | (should (eq (car (python-indent-context)) :after-line)) | 207 | (should (eq (car (python-indent-context)) :after-comment)) |
| 208 | (should (= (python-indent-calculate-indentation) 0)) | 208 | (should (= (python-indent-calculate-indentation) 0)) |
| 209 | (python-tests-look-at "var_three, var_four)") | 209 | (python-tests-look-at "var_three, var_four)") |
| 210 | (should (eq (car (python-indent-context)) :inside-paren)) | 210 | (should (eq (car (python-indent-context)) :inside-paren)) |
| @@ -222,7 +222,7 @@ def long_function_name( | |||
| 222 | (should (eq (car (python-indent-context)) :no-indent)) | 222 | (should (eq (car (python-indent-context)) :no-indent)) |
| 223 | (should (= (python-indent-calculate-indentation) 0)) | 223 | (should (= (python-indent-calculate-indentation) 0)) |
| 224 | (python-tests-look-at "def long_function_name(") | 224 | (python-tests-look-at "def long_function_name(") |
| 225 | (should (eq (car (python-indent-context)) :after-line)) | 225 | (should (eq (car (python-indent-context)) :after-comment)) |
| 226 | (should (= (python-indent-calculate-indentation) 0)) | 226 | (should (= (python-indent-calculate-indentation) 0)) |
| 227 | (python-tests-look-at "var_one, var_two, var_three,") | 227 | (python-tests-look-at "var_one, var_two, var_three,") |
| 228 | (should (eq (car (python-indent-context)) | 228 | (should (eq (car (python-indent-context)) |
| @@ -248,7 +248,7 @@ foo = long_function_name( | |||
| 248 | (should (eq (car (python-indent-context)) :no-indent)) | 248 | (should (eq (car (python-indent-context)) :no-indent)) |
| 249 | (should (= (python-indent-calculate-indentation) 0)) | 249 | (should (= (python-indent-calculate-indentation) 0)) |
| 250 | (python-tests-look-at "foo = long_function_name(") | 250 | (python-tests-look-at "foo = long_function_name(") |
| 251 | (should (eq (car (python-indent-context)) :after-line)) | 251 | (should (eq (car (python-indent-context)) :after-comment)) |
| 252 | (should (= (python-indent-calculate-indentation) 0)) | 252 | (should (= (python-indent-calculate-indentation) 0)) |
| 253 | (python-tests-look-at "var_one, var_two,") | 253 | (python-tests-look-at "var_one, var_two,") |
| 254 | (should (eq (car (python-indent-context)) :inside-paren-newline-start)) | 254 | (should (eq (car (python-indent-context)) :inside-paren-newline-start)) |
| @@ -313,10 +313,10 @@ class Blag(object): | |||
| 313 | def func(arg): | 313 | def func(arg): |
| 314 | # I don't do much | 314 | # I don't do much |
| 315 | return arg | 315 | return arg |
| 316 | # This comment is badly indented just because. | 316 | # This comment is badly indented because the user forced so. |
| 317 | # But we won't mess with the user in this line. | 317 | # At this line python.el wont dedent, user is always right. |
| 318 | 318 | ||
| 319 | now_we_do_mess_cause_this_is_not_a_comment = 1 | 319 | comment_wins_over_ender = True |
| 320 | 320 | ||
| 321 | # yeah, that. | 321 | # yeah, that. |
| 322 | " | 322 | " |
| @@ -328,28 +328,49 @@ now_we_do_mess_cause_this_is_not_a_comment = 1 | |||
| 328 | ;; the rules won't apply here. | 328 | ;; the rules won't apply here. |
| 329 | (should (eq (car (python-indent-context)) :after-block-start)) | 329 | (should (eq (car (python-indent-context)) :after-block-start)) |
| 330 | (should (= (python-indent-calculate-indentation) 4)) | 330 | (should (= (python-indent-calculate-indentation) 4)) |
| 331 | (python-tests-look-at "# This comment is badly") | 331 | (python-tests-look-at "# This comment is badly indented") |
| 332 | (should (eq (car (python-indent-context)) :after-block-end)) | 332 | (should (eq (car (python-indent-context)) :after-block-end)) |
| 333 | ;; The return keyword moves indentation backwards 4 spaces, but | 333 | ;; The return keyword do make indentation lose a level... |
| 334 | ;; let's assume this comment was placed there because the user | ||
| 335 | ;; wanted to (manually adding spaces or whatever). | ||
| 336 | (should (= (python-indent-calculate-indentation) 0)) | 334 | (should (= (python-indent-calculate-indentation) 0)) |
| 337 | (python-tests-look-at "# but we won't mess") | 335 | ;; ...but the current indentation was forced by the user. |
| 336 | (python-tests-look-at "# At this line python.el wont dedent") | ||
| 338 | (should (eq (car (python-indent-context)) :after-comment)) | 337 | (should (eq (car (python-indent-context)) :after-comment)) |
| 339 | (should (= (python-indent-calculate-indentation) 4)) | 338 | (should (= (python-indent-calculate-indentation) 4)) |
| 340 | ;; Behave the same for blank lines: potentially a comment. | 339 | ;; Should behave the same for blank lines: potentially a comment. |
| 341 | (forward-line 1) | 340 | (forward-line 1) |
| 342 | (should (eq (car (python-indent-context)) :after-comment)) | 341 | (should (eq (car (python-indent-context)) :after-comment)) |
| 343 | (should (= (python-indent-calculate-indentation) 4)) | 342 | (should (= (python-indent-calculate-indentation) 4)) |
| 344 | (python-tests-look-at "now_we_do_mess") | 343 | (python-tests-look-at "comment_wins_over_ender") |
| 345 | ;; Here is where comment indentation starts to get ignored and | 344 | ;; The comment won over the ender because the user said so. |
| 346 | ;; where the user can't freely indent anymore. | 345 | (should (eq (car (python-indent-context)) :after-comment)) |
| 347 | (should (eq (car (python-indent-context)) :after-block-end)) | 346 | (should (= (python-indent-calculate-indentation) 4)) |
| 348 | (should (= (python-indent-calculate-indentation) 0)) | 347 | ;; The indentation calculated fine for the assignment, but the user |
| 348 | ;; choose to force it back to the first column. Next line should | ||
| 349 | ;; be aware of that. | ||
| 349 | (python-tests-look-at "# yeah, that.") | 350 | (python-tests-look-at "# yeah, that.") |
| 350 | (should (eq (car (python-indent-context)) :after-line)) | 351 | (should (eq (car (python-indent-context)) :after-line)) |
| 351 | (should (= (python-indent-calculate-indentation) 0)))) | 352 | (should (= (python-indent-calculate-indentation) 0)))) |
| 352 | 353 | ||
| 354 | (ert-deftest python-indent-after-comment-3 () | ||
| 355 | "Test after-comment in buggy case." | ||
| 356 | (python-tests-with-temp-buffer | ||
| 357 | " | ||
| 358 | class A(object): | ||
| 359 | |||
| 360 | def something(self, arg): | ||
| 361 | if True: | ||
| 362 | return arg | ||
| 363 | |||
| 364 | # A comment | ||
| 365 | |||
| 366 | @adecorator | ||
| 367 | def method(self, a, b): | ||
| 368 | pass | ||
| 369 | " | ||
| 370 | (python-tests-look-at "@adecorator") | ||
| 371 | (should (eq (car (python-indent-context)) :after-comment)) | ||
| 372 | (should (= (python-indent-calculate-indentation) 4)))) | ||
| 373 | |||
| 353 | (ert-deftest python-indent-inside-paren-1 () | 374 | (ert-deftest python-indent-inside-paren-1 () |
| 354 | "The most simple inside-paren case that shouldn't fail." | 375 | "The most simple inside-paren case that shouldn't fail." |
| 355 | (python-tests-with-temp-buffer | 376 | (python-tests-with-temp-buffer |
| @@ -2133,6 +2154,55 @@ if True: | |||
| 2133 | (call-interactively #'python-indent-dedent-line-backspace) | 2154 | (call-interactively #'python-indent-dedent-line-backspace) |
| 2134 | (should (zerop (current-indentation))))) | 2155 | (should (zerop (current-indentation))))) |
| 2135 | 2156 | ||
| 2157 | (ert-deftest python-indent-dedent-line-backspace-2 () | ||
| 2158 | "Check de-indentation with tabs. Bug#19730." | ||
| 2159 | (let ((tab-width 8)) | ||
| 2160 | (python-tests-with-temp-buffer | ||
| 2161 | " | ||
| 2162 | if x: | ||
| 2163 | \tabcdefg | ||
| 2164 | " | ||
| 2165 | (python-tests-look-at "abcdefg") | ||
| 2166 | (goto-char (line-end-position)) | ||
| 2167 | (call-interactively #'python-indent-dedent-line-backspace) | ||
| 2168 | (should | ||
| 2169 | (string= (buffer-substring-no-properties | ||
| 2170 | (line-beginning-position) (line-end-position)) | ||
| 2171 | "\tabcdef"))))) | ||
| 2172 | |||
| 2173 | (ert-deftest python-indent-dedent-line-backspace-3 () | ||
| 2174 | "Paranoid check of de-indentation with tabs. Bug#19730." | ||
| 2175 | (let ((tab-width 8)) | ||
| 2176 | (python-tests-with-temp-buffer | ||
| 2177 | " | ||
| 2178 | if x: | ||
| 2179 | \tif y: | ||
| 2180 | \t abcdefg | ||
| 2181 | " | ||
| 2182 | (python-tests-look-at "abcdefg") | ||
| 2183 | (goto-char (line-end-position)) | ||
| 2184 | (call-interactively #'python-indent-dedent-line-backspace) | ||
| 2185 | (should | ||
| 2186 | (string= (buffer-substring-no-properties | ||
| 2187 | (line-beginning-position) (line-end-position)) | ||
| 2188 | "\t abcdef")) | ||
| 2189 | (back-to-indentation) | ||
| 2190 | (call-interactively #'python-indent-dedent-line-backspace) | ||
| 2191 | (should | ||
| 2192 | (string= (buffer-substring-no-properties | ||
| 2193 | (line-beginning-position) (line-end-position)) | ||
| 2194 | "\tabcdef")) | ||
| 2195 | (call-interactively #'python-indent-dedent-line-backspace) | ||
| 2196 | (should | ||
| 2197 | (string= (buffer-substring-no-properties | ||
| 2198 | (line-beginning-position) (line-end-position)) | ||
| 2199 | " abcdef")) | ||
| 2200 | (call-interactively #'python-indent-dedent-line-backspace) | ||
| 2201 | (should | ||
| 2202 | (string= (buffer-substring-no-properties | ||
| 2203 | (line-beginning-position) (line-end-position)) | ||
| 2204 | "abcdef"))))) | ||
| 2205 | |||
| 2136 | 2206 | ||
| 2137 | ;;; Shell integration | 2207 | ;;; Shell integration |
| 2138 | 2208 | ||