diff options
Diffstat (limited to 'test/lisp/progmodes/python-tests.el')
-rw-r--r-- | test/lisp/progmodes/python-tests.el | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index a44724f1dca..b1cf7e8806a 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -270,6 +270,19 @@ foo = long_function_name( (should (eq (car (python-indent-context)) :inside-paren-newline-start)) (should (= (python-indent-calculate-indentation) 4)))) +(ert-deftest python-indent-hanging-close-paren () + "Like first pep8 case, but with hanging close paren." ;; See Bug#20742. + (python-tests-with-temp-buffer + "\ +foo = long_function_name(var_one, var_two, + var_three, var_four + ) +" + (should (= (python-indent-calculate-indentation) 0)) + (python-tests-look-at ")") + (should (eq (car (python-indent-context)) :inside-paren-at-closing-paren)) + (should (= (python-indent-calculate-indentation) 25)))) + (ert-deftest python-indent-base-case () "Check base case does not trigger errors." (python-tests-with-temp-buffer @@ -1171,10 +1184,13 @@ def b() if do: something() else +outside " (python-tests-look-at "else") (goto-char (line-end-position)) (python-tests-self-insert ":") + (should (= (current-indentation) 0)) + (python-tests-look-at "outside") (should (= (current-indentation) 0)))) (ert-deftest python-indent-electric-colon-3 () @@ -1335,6 +1351,24 @@ this is an arbitrarily expected))))) +;;; Autofill + +(ert-deftest python-auto-fill-docstring () + (python-tests-with-temp-buffer + "\ +def some_function(arg1, + arg2): + \"\"\" + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." + (auto-fill-mode +1) + (goto-char (point-max)) + (newline) + (search-backward "Lorem") + (let ((docindent (current-indentation))) + (forward-line 1) + (should (= docindent (current-indentation)))))) + + ;;; Mark (ert-deftest python-mark-defun-1 () @@ -2014,6 +2048,12 @@ string (python-util-forward-comment -1) (point)))))) +(ert-deftest python-nav-end-of-statement-2 () + "Test the string overlap assertion (Bug#30964)." + (python-tests-with-temp-buffer + "'\n''\n" + (python-nav-end-of-statement))) + (ert-deftest python-nav-forward-statement-1 () (python-tests-with-temp-buffer " @@ -5346,13 +5386,23 @@ class SomeClass: (ert-deftest python-tests--python-nav-end-of-statement--infloop () "Checks that `python-nav-end-of-statement' doesn't infloop in a buffer with overlapping strings." + ;; FIXME: The treatment of strings has changed in the mean time, and the + ;; test below now neither signals an error nor inf-loops. + ;; The description of the problem it's trying to catch is not clear enough + ;; to be able to see if the underlying problem is really fixed, sadly. + ;; E.g. I don't know what is meant by "overlap", really. + :tags '(:unstable) (python-tests-with-temp-buffer "''' '\n''' ' '\n" (syntax-propertize (point-max)) ;; Create a situation where strings nominally overlap. This ;; shouldn't happen in practice, but apparently it can happen when ;; a package calls `syntax-ppss' in a narrowed buffer during JIT ;; lock. + ;; FIXME: 4-5 is the SPC right after the opening triple quotes: why + ;; put a string-fence syntax on it? (put-text-property 4 5 'syntax-table (string-to-syntax "|")) + ;; FIXME: 8-9 is the middle quote in the closing triple quotes: + ;; it shouldn't have any syntax-table property to remove anyway! (remove-text-properties 8 9 '(syntax-table nil)) (goto-char 4) (setq-local syntax-propertize-function nil) @@ -5362,6 +5412,15 @@ buffer with overlapping strings." (python-nav-end-of-statement))) (should (eolp)))) +;; After call `run-python' the buffer running the python process is current. +(ert-deftest python-tests--bug31398 () + "Test for https://debbugs.gnu.org/31398 ." + (skip-unless (executable-find python-tests-shell-interpreter)) + (let ((buffer (process-buffer (run-python nil nil 'show)))) + (should (eq buffer (current-buffer))) + (pop-to-buffer (other-buffer)) + (run-python nil nil 'show) + (should (eq buffer (current-buffer))))) (provide 'python-tests) |