1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-10 08:10:21 -08:00

Fix python-shell-buffer-substring when retrieving a single statement

* lisp/progmodes/python.el (python-shell-buffer-substring): Do not add
"if True:" line when retrieving a single statement.
(python-shell-send-region): Add a reference to
`python-shell-buffer-substring' in docstring.
* test/lisp/progmodes/python-tests.el (python-shell-buffer-substring-13)
(python-shell-buffer-substring-14, python-shell-buffer-substring-15)
(python-shell-buffer-substring-16, python-shell-buffer-substring-17):
New tests. (Bug#60142)
This commit is contained in:
kobarity 2022-12-22 23:08:40 +09:00 committed by Eli Zaretskii
parent bfdad6c4e5
commit eee2aeca25
2 changed files with 95 additions and 14 deletions

View file

@ -4456,6 +4456,70 @@ def foo():
(point-max))
"# -*- coding: utf-8 -*-\n\nif True:\n # Whitespace\n\n print ('a')\n\n"))))
(ert-deftest python-shell-buffer-substring-13 ()
"Check substring from indented single statement."
(python-tests-with-temp-buffer
"
def foo():
a = 1
"
(should (string= (python-shell-buffer-substring
(python-tests-look-at "a = 1")
(pos-eol))
"# -*- coding: utf-8 -*-\n\na = 1"))))
(ert-deftest python-shell-buffer-substring-14 ()
"Check substring from indented single statement spanning multiple lines."
(python-tests-with-temp-buffer
"
def foo():
a = \"\"\"Some
string\"\"\"
"
(should (string= (python-shell-buffer-substring
(python-tests-look-at "a = \"\"\"Some")
(pos-eol 2))
"# -*- coding: utf-8 -*-\n\na = \"\"\"Some\n string\"\"\""))))
(ert-deftest python-shell-buffer-substring-15 ()
"Check substring from partial statement."
(python-tests-with-temp-buffer
"
def foo():
a = 1
"
(should (string= (python-shell-buffer-substring
(python-tests-look-at " a = 1")
(python-tests-look-at " = 1"))
"# -*- coding: utf-8 -*-\n\na"))))
(ert-deftest python-shell-buffer-substring-16 ()
"Check substring from partial statement."
(python-tests-with-temp-buffer
"
def foo():
a = 1
"
(should (string= (python-shell-buffer-substring
(python-tests-look-at "1")
(1+ (point)))
"# -*- coding: utf-8 -*-\n\n1"))))
(ert-deftest python-shell-buffer-substring-17 ()
"Check substring from multiline string."
(python-tests-with-temp-buffer
"
def foo():
s = \"\"\"
a = 1
b = 2
\"\"\"
"
(should (string= (python-shell-buffer-substring
(python-tests-look-at "a = 1")
(python-tests-look-at "\"\"\""))
"# -*- coding: utf-8 -*-\n\nif True:\n a = 1\n b = 2\n\n"))))
;;; Shell completion