diff options
| author | Lin Sun | 2024-04-27 06:54:27 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 2024-05-02 12:56:31 +0300 |
| commit | b2e92c746eb7d1135d3d4ccecc774d79555ffb99 (patch) | |
| tree | 09e6292e053fdf3b3558e98a653e7740d14c6401 /test/lisp/progmodes/python-tests.el | |
| parent | bf00762745c07816e7a9c64e0fce037039852971 (diff) | |
| download | emacs-b2e92c746eb7d1135d3d4ccecc774d79555ffb99.tar.gz emacs-b2e92c746eb7d1135d3d4ccecc774d79555ffb99.zip | |
New function 'python-shell-send-block' for python-mode
* lisp/progmodes/python.el (python-shell-send-block): New
function.
* test/lisp/progmodes/python-tests.el
(python-test--shell-send-block): Test case for the new
function.
* etc/NEWS: Document 'python-shell-send-block'.
(Bug#70609)
Diffstat (limited to 'test/lisp/progmodes/python-tests.el')
| -rw-r--r-- | test/lisp/progmodes/python-tests.el | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index e3b1642a975..889038d0f8c 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el | |||
| @@ -7466,6 +7466,33 @@ buffer with overlapping strings." | |||
| 7466 | "Unused import a.b.c (unused-import)" | 7466 | "Unused import a.b.c (unused-import)" |
| 7467 | "W0611: Unused import a.b.c (unused-import)")))))) | 7467 | "W0611: Unused import a.b.c (unused-import)")))))) |
| 7468 | 7468 | ||
| 7469 | (ert-deftest python-test--shell-send-block () | ||
| 7470 | (skip-unless (executable-find python-tests-shell-interpreter)) | ||
| 7471 | (python-tests-with-temp-buffer-with-shell | ||
| 7472 | "print('current 0') | ||
| 7473 | for x in range(1,3): | ||
| 7474 | print('current %s' % x) | ||
| 7475 | print('current 3')" | ||
| 7476 | (goto-line 1) | ||
| 7477 | (should-error (python-shell-send-block) :type 'user-error) | ||
| 7478 | (goto-line 2) | ||
| 7479 | (python-shell-send-block) | ||
| 7480 | (python-tests-shell-wait-for-prompt) | ||
| 7481 | (python-shell-with-shell-buffer | ||
| 7482 | (goto-char (point-min)) | ||
| 7483 | (should-not (re-search-forward "current 0" nil t)) | ||
| 7484 | (should (re-search-forward "current 1" nil t)) | ||
| 7485 | (should (re-search-forward "current 2" nil t)) | ||
| 7486 | (should-not (re-search-forward "current 3" nil t))) | ||
| 7487 | (goto-line 3) | ||
| 7488 | (python-shell-send-block t) ;; send block body only | ||
| 7489 | (python-tests-shell-wait-for-prompt) | ||
| 7490 | (python-shell-with-shell-buffer | ||
| 7491 | ;; should only 1 line output from the block body | ||
| 7492 | (should (re-search-forward "current")) | ||
| 7493 | (should (looking-at " 2")) | ||
| 7494 | (should-not (re-search-forward "current" nil t))))) | ||
| 7495 | |||
| 7469 | ;;; python-ts-mode font-lock tests | 7496 | ;;; python-ts-mode font-lock tests |
| 7470 | 7497 | ||
| 7471 | (defmacro python-ts-tests-with-temp-buffer (contents &rest body) | 7498 | (defmacro python-ts-tests-with-temp-buffer (contents &rest body) |