summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lisp/progmodes/python-tests.el64
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