From: kobarity <kobarity@gmail.com>
To: Lin Sun <sunlin7.mail@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>,
Stefan Kangas <stefankangas@gmail.com>,
70815@debbugs.gnu.org
Subject: bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
Date: Tue, 21 May 2024 00:52:34 +0900 [thread overview]
Message-ID: <eke7bk50lbul.wl-kobarity@gmail.com> (raw)
In-Reply-To: <CABCREdq2D3NhmEyGseEKyEfYmqS_CvFT9b-CtOM8E+YX-HMdxw@mail.gmail.com> <86zfsmbb3b.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 1621 bytes --]
Eli Zaretskii wrote:
> > Cc: kobarity <kobarity@gmail.com>
> > From: Stefan Kangas <stefankangas@gmail.com>
> > Date: Sat, 18 May 2024 22:20:44 +0000
> >
> > It makes sense to look for "python3", but is it really useful to look
> > for "python2" at this point?
> I don't think we want to drop Python 2.x support, not yet.
I don't want to drop Python 2 support either, but I don't think the
addition of the "python2" command is mandatory. As the current master
does not run the "python2" command either. However, I don't think it
is a bad idea to add the "python2" command.
Lin Sun wrote:
> Hi,
> I attached the latest patch, hope it resolved all your concerns.
Hi Lin,
There is still a typo "Enahnce" in the summary line, and there is a
typo in the docstring of `python-tests-get-shell-interpreter' as well.
> > If there is only python2 in the PATH and no python or python3, some tests will fail.
> It's caused by the python.el didn't search "python2", so it may need
> another patch to change python.el.
I don't think so. Attached is a diff to your patch to resolve this
issue. It let-binds `python-shell-interpreter' in some ERTs. It
also includes the fix of the typo in the docstring of
`python-tests-get-shell-interpreter'.
Without these modifications, EMACS_PYTHON_INTERPRETER will not work as
expected either on those ERTs.
As for EMACS_PYTHON_INTERPRETER, I am a little doubtful that it is the
right thing to introduce. It allows the ERT runner to specify the
interpreter. It's OK for ERTs that can be run on both Python 2 and 3,
but you may want to write an ERT that can only be run on Python 3.
[-- Attachment #2: fix-70815.diff --]
[-- Type: application/octet-stream, Size: 3486 bytes --]
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
index 3bedf86fb5f..fa8fa74fa88 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -59,7 +59,8 @@ python-tests-with-temp-buffer-with-shell
(let ((dir (make-symbol "dir")))
`(with-temp-buffer
(let ((python-indent-guess-indent-offset nil)
- (python-shell-completion-native-enable nil))
+ (python-shell-completion-native-enable nil)
+ (python-shell-interpreter (python-tests-get-shell-interpreter)))
(python-mode)
(unwind-protect
;; Prevent test failures when Jedi is used as a completion
@@ -3743,7 +3744,7 @@ python-tests-shell-interpreter
(defun python-tests-get-shell-interpreter ()
"Get the shell interpreter.
-If env string EMACS_PYTHON_INTERPRETER exists, use it as prefered one."
+If env string EMACS_PYTHON_INTERPRETER exists, use it as preferred one."
(if python-tests-shell-interpreter
python-tests-shell-interpreter
(setq python-tests-shell-interpreter
@@ -4188,8 +4189,9 @@ python-shell-internal-get-or-create-process-1
(ert-deftest python-shell-prompt-detect-1 ()
"Check prompt autodetection."
- (skip-unless (python-tests-get-shell-interpreter))
- (let ((process-environment process-environment))
+ (let ((process-environment process-environment)
+ (python-shell-interpreter (python-tests-get-shell-interpreter)))
+ (skip-unless python-shell-interpreter)
;; Ensure no startup file is enabled
(setenv "PYTHONSTARTUP" "")
(should python-shell-prompt-detect-enabled)
@@ -4197,13 +4199,14 @@ python-shell-prompt-detect-1
(ert-deftest python-shell-prompt-detect-2 ()
"Check prompt autodetection with startup file. Bug#17370."
- (skip-unless (python-tests-get-shell-interpreter))
(let* ((process-environment process-environment)
+ (python-shell-interpreter (python-tests-get-shell-interpreter))
(startup-code (concat "import sys\n"
"sys.ps1 = 'py> '\n"
"sys.ps2 = '..> '\n"
"sys.ps3 = 'out '\n"))
(startup-file (python-shell--save-temp-file startup-code)))
+ (skip-unless python-shell-interpreter)
(unwind-protect
(progn
;; Ensure startup file is enabled
@@ -4439,6 +4442,7 @@ python-shell-prompt-set-calculated-regexps-6
(python-shell--prompt-calculated-input-regexp nil)
(python-shell--prompt-calculated-output-regexp nil)
(python-shell-prompt-detect-enabled t)
+ (python-shell-interpreter (python-tests-get-shell-interpreter))
(process-environment process-environment)
(startup-code (concat "import sys\n"
"sys.ps1 = 'p.> '\n"
@@ -7430,7 +7434,8 @@ python-tests--python-nav-end-of-statement--infloop
(ert-deftest python-tests--run-python-selects-window ()
"Test for bug#31398. See also bug#44421 and bug#52380."
(skip-unless (python-tests-get-shell-interpreter))
- (let* ((buffer (process-buffer (run-python nil nil 'show)))
+ (let* ((python-shell-interpreter (python-tests-get-shell-interpreter))
+ (buffer (process-buffer (run-python nil nil 'show)))
(window (get-buffer-window buffer)))
;; We look at `selected-window' rather than `current-buffer'
;; because as `(elisp)Current buffer' says, the latter will only
next prev parent reply other threads:[~2024-05-20 15:52 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-07 6:53 bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters Lin Sun
2024-05-11 9:05 ` Eli Zaretskii
2024-05-11 13:37 ` kobarity
2024-05-11 14:27 ` Lin Sun
2024-05-12 2:06 ` kobarity
2024-05-18 22:20 ` Stefan Kangas
2024-05-19 5:54 ` Eli Zaretskii
2024-05-20 0:08 ` Lin Sun
2024-05-20 15:52 ` kobarity [this message]
2024-05-20 17:51 ` Lin Sun
2024-05-21 14:04 ` kobarity
2024-05-21 15:34 ` Lin Sun
2024-05-22 14:38 ` kobarity
2024-05-23 13:09 ` Eli Zaretskii
2024-05-26 10:52 ` Mattias Engdegård
2024-05-26 12:05 ` kobarity
2024-05-26 12:21 ` Mattias Engdegård
2024-05-26 12:36 ` kobarity
2024-05-26 13:23 ` Mattias Engdegård
2024-05-26 14:15 ` kobarity
2024-05-26 15:00 ` kobarity
2024-05-26 15:24 ` Mattias Engdegård
2024-05-27 12:33 ` kobarity
2024-05-27 12:45 ` Eli Zaretskii
2024-05-28 12:30 ` Mattias Engdegård
2024-05-28 15:17 ` kobarity
2024-05-28 16:09 ` Mattias Engdegård
2024-05-29 14:56 ` kobarity
2024-05-30 10:09 ` Mattias Engdegård
2024-06-02 13:20 ` kobarity
2024-06-03 14:02 ` Mattias Engdegård
2024-06-03 14:34 ` kobarity
2024-06-03 16:24 ` kobarity
2024-06-04 14:29 ` kobarity
2024-06-05 10:25 ` Mattias Engdegård
2024-06-05 11:52 ` kobarity
2024-06-08 15:34 ` kobarity
2024-06-09 13:58 ` Mattias Engdegård
2024-06-10 14:57 ` kobarity
2024-06-10 15:44 ` Mattias Engdegård
2024-05-26 15:56 ` Eli Zaretskii
2024-05-26 23:06 ` Stefan Kangas
2024-05-27 11:18 ` Eli Zaretskii
2024-05-27 12:20 ` Mattias Engdegård
2024-05-27 12:43 ` Eli Zaretskii
2024-05-26 15:52 ` Eli Zaretskii
2024-05-27 10:24 ` Mattias Engdegård
2024-05-27 11:19 ` Lin Sun
2024-05-26 15:36 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=eke7bk50lbul.wl-kobarity@gmail.com \
--to=kobarity@gmail.com \
--cc=70815@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=stefankangas@gmail.com \
--cc=sunlin7.mail@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).