diff options
author | kobarity <kobarity@gmail.com> | 2022-12-22 23:08:40 +0900 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2022-12-31 10:14:28 +0200 |
commit | eee2aeca251a6fb3db09cfeeb3ae3aaf48db02fc (patch) | |
tree | 3643b7b2de10f7ce10e298c65cdc90dbe6bc7e6d /test/lisp/progmodes/python-tests.el | |
parent | bfdad6c4e5ce95025f1761a404b762589d126505 (diff) | |
download | emacs-eee2aeca251a6fb3db09cfeeb3ae3aaf48db02fc.tar.gz emacs-eee2aeca251a6fb3db09cfeeb3ae3aaf48db02fc.tar.bz2 emacs-eee2aeca251a6fb3db09cfeeb3ae3aaf48db02fc.zip |
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)
Diffstat (limited to 'test/lisp/progmodes/python-tests.el')
-rw-r--r-- | test/lisp/progmodes/python-tests.el | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index 17d6d8aa706..930234a12f2 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -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 |