diff options
| author | kobarity | 2022-10-22 21:36:15 +0900 |
|---|---|---|
| committer | Eli Zaretskii | 2022-10-27 19:04:14 +0300 |
| commit | 7ac3d91eb2a7e9454087f17e1fadba350a86a208 (patch) | |
| tree | 96df09ecf27e5da25fa943058afa46357cb60033 /test/lisp/progmodes/python-tests.el | |
| parent | d820c39bd18e493ba716ad3ceb8101c1dee3a02b (diff) | |
| download | emacs-7ac3d91eb2a7e9454087f17e1fadba350a86a208.tar.gz emacs-7ac3d91eb2a7e9454087f17e1fadba350a86a208.zip | |
Disable completion/ElDoc/FFAP when Python program is running
* lisp/progmodes/python.el (python-completion-at-point)
(python-ffap-module-path, python-eldoc--get-doc-at-point): Add check
using `python-util-comint-end-of-output-p'.
(python-util-comint-end-of-output-p): New function.
* test/lisp/progmodes/python-tests.el (python-tests-shell-wait-for-prompt):
Use `python-util-comint-end-of-output-p'.
(python-completion-at-point-while-running-1)
(python-ffap-module-path-1)
(python-ffap-module-path-while-running-1)
(python-eldoc--get-doc-at-point-1)
(python-eldoc--get-doc-at-point-while-running-1): New tests.
(Bug#58713)
Diffstat (limited to 'test/lisp/progmodes/python-tests.el')
| -rw-r--r-- | test/lisp/progmodes/python-tests.el | 71 |
1 files changed, 67 insertions, 4 deletions
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index 81c9217c62c..8330525394c 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el | |||
| @@ -46,10 +46,7 @@ always located at the beginning of buffer." | |||
| 46 | (defun python-tests-shell-wait-for-prompt () | 46 | (defun python-tests-shell-wait-for-prompt () |
| 47 | "Wait for the prompt in the shell buffer." | 47 | "Wait for the prompt in the shell buffer." |
| 48 | (python-shell-with-shell-buffer | 48 | (python-shell-with-shell-buffer |
| 49 | (while (not (if-let ((prompt (python-util-comint-last-prompt))) | 49 | (while (not (python-util-comint-end-of-output-p)) |
| 50 | (python-shell-comint-end-of-output-p | ||
| 51 | (buffer-substring-no-properties | ||
| 52 | (car prompt) (cdr prompt))))) | ||
| 53 | (sit-for 0.1)))) | 50 | (sit-for 0.1)))) |
| 54 | 51 | ||
| 55 | (defmacro python-tests-with-temp-buffer-with-shell (contents &rest body) | 52 | (defmacro python-tests-with-temp-buffer-with-shell (contents &rest body) |
| @@ -4478,6 +4475,21 @@ print('Hello') | |||
| 4478 | (insert "u") | 4475 | (insert "u") |
| 4479 | (should-not (nth 2 (python-completion-at-point)))))) | 4476 | (should-not (nth 2 (python-completion-at-point)))))) |
| 4480 | 4477 | ||
| 4478 | (ert-deftest python-completion-at-point-while-running-1 () | ||
| 4479 | "Should not try to complete when a program is running in the Shell buffer." | ||
| 4480 | (skip-unless (executable-find python-tests-shell-interpreter)) | ||
| 4481 | (python-tests-with-temp-buffer-with-shell | ||
| 4482 | " | ||
| 4483 | import time | ||
| 4484 | |||
| 4485 | time.sleep(3) | ||
| 4486 | " | ||
| 4487 | (let ((inhibit-message t)) | ||
| 4488 | (python-shell-send-buffer) | ||
| 4489 | (goto-char (point-max)) | ||
| 4490 | (insert "time.") | ||
| 4491 | (should-not (with-timeout (1 t) (completion-at-point)))))) | ||
| 4492 | |||
| 4481 | (ert-deftest python-completion-at-point-native-1 () | 4493 | (ert-deftest python-completion-at-point-native-1 () |
| 4482 | (skip-unless (executable-find python-tests-shell-interpreter)) | 4494 | (skip-unless (executable-find python-tests-shell-interpreter)) |
| 4483 | (python-tests-with-temp-buffer-with-shell | 4495 | (python-tests-with-temp-buffer-with-shell |
| @@ -4552,6 +4564,31 @@ import abc | |||
| 4552 | 4564 | ||
| 4553 | ;;; FFAP | 4565 | ;;; FFAP |
| 4554 | 4566 | ||
| 4567 | (ert-deftest python-ffap-module-path-1 () | ||
| 4568 | (skip-unless (executable-find python-tests-shell-interpreter)) | ||
| 4569 | (python-tests-with-temp-buffer-with-shell | ||
| 4570 | " | ||
| 4571 | import abc | ||
| 4572 | " | ||
| 4573 | (let ((inhibit-message t)) | ||
| 4574 | (python-shell-send-buffer) | ||
| 4575 | (python-tests-shell-wait-for-prompt) | ||
| 4576 | (should (file-exists-p (python-ffap-module-path "abc")))))) | ||
| 4577 | |||
| 4578 | (ert-deftest python-ffap-module-path-while-running-1 () | ||
| 4579 | "Should not get module path when a program is running in the Shell buffer." | ||
| 4580 | (skip-unless (executable-find python-tests-shell-interpreter)) | ||
| 4581 | (python-tests-with-temp-buffer-with-shell | ||
| 4582 | " | ||
| 4583 | import abc | ||
| 4584 | import time | ||
| 4585 | |||
| 4586 | time.sleep(3) | ||
| 4587 | " | ||
| 4588 | (let ((inhibit-message t)) | ||
| 4589 | (python-shell-send-buffer) | ||
| 4590 | (should-not (with-timeout (1 t) (python-ffap-module-path "abc")))))) | ||
| 4591 | |||
| 4555 | 4592 | ||
| 4556 | ;;; Code check | 4593 | ;;; Code check |
| 4557 | 4594 | ||
| @@ -4615,6 +4652,32 @@ some_symbol some_other_symbol | |||
| 4615 | (should (string= (python-eldoc--get-symbol-at-point) | 4652 | (should (string= (python-eldoc--get-symbol-at-point) |
| 4616 | "some_symbol")))) | 4653 | "some_symbol")))) |
| 4617 | 4654 | ||
| 4655 | (ert-deftest python-eldoc--get-doc-at-point-1 () | ||
| 4656 | (skip-unless (executable-find python-tests-shell-interpreter)) | ||
| 4657 | (python-tests-with-temp-buffer-with-shell | ||
| 4658 | " | ||
| 4659 | import time | ||
| 4660 | " | ||
| 4661 | (let ((inhibit-message t)) | ||
| 4662 | (python-shell-send-buffer) | ||
| 4663 | (python-tests-shell-wait-for-prompt) | ||
| 4664 | (python-tests-look-at "time") | ||
| 4665 | (should (python-eldoc--get-doc-at-point))))) | ||
| 4666 | |||
| 4667 | (ert-deftest python-eldoc--get-doc-at-point-while-running-1 () | ||
| 4668 | "Should not get documentation when a program is running in the Shell buffer." | ||
| 4669 | (skip-unless (executable-find python-tests-shell-interpreter)) | ||
| 4670 | (python-tests-with-temp-buffer-with-shell | ||
| 4671 | " | ||
| 4672 | import time | ||
| 4673 | |||
| 4674 | time.sleep(3) | ||
| 4675 | " | ||
| 4676 | (let ((inhibit-message t)) | ||
| 4677 | (python-shell-send-buffer) | ||
| 4678 | (python-tests-look-at "time") | ||
| 4679 | (should-not (with-timeout (1 t) (python-eldoc--get-doc-at-point)))))) | ||
| 4680 | |||
| 4618 | 4681 | ||
| 4619 | ;;; Imenu | 4682 | ;;; Imenu |
| 4620 | 4683 | ||