all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
@ 2024-05-07  6:53 Lin Sun
  2024-05-11  9:05 ` Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 49+ messages in thread
From: Lin Sun @ 2024-05-07  6:53 UTC (permalink / raw)
  To: 70815

[-- Attachment #1: Type: text/plain, Size: 453 bytes --]

Hi,
The python-tests.el will fail on finding interpreter "python" for
there is no "python"  on CentOS8, Ubuntu 20.04,  only "python3" exists
after installation.

And the patch will try to search python/python3/python2 as the python
testing interpreter; it also support a env var
"EMACS_PYTHON_INTERPRETER" to switch between different version of
python (eg: python3.6, python3.11, ...).

Please help review the  enhancement in "python-tests.el". Thanks.

[-- Attachment #2: 0001-Enahnce-python-tests.el-to-adapt-different-python-in.patch --]
[-- Type: text/x-patch, Size: 15880 bytes --]

From 49dfcecbbffaf15aa0414d15f22d8bcbf768ebb3 Mon Sep 17 00:00:00 2001
From: Lin Sun <sunlin7@hotmail.com>
Date: Fri, 3 May 2024 06:52:22 +0000
Subject: [PATCH] ; Enahnce python-tests.el to adapt different python
 interpreters

* test/lisp/progmodes/python-tests.el
  (python-tests-get-shell-interpreter): New function to get python
  interpreter for testing.
---
 test/lisp/progmodes/python-tests.el | 87 ++++++++++++++++-------------
 1 file changed, 48 insertions(+), 39 deletions(-)

diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
index f50797953c3..6da149925ec 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -3718,7 +3718,16 @@ if x:
 \f
 ;;; Shell integration
 
-(defvar python-tests-shell-interpreter "python")
+(defvar python-tests-shell-interpreter nil)
+
+(defun python-tests-get-shell-interpreter (&optional refresh)
+  (if (and python-tests-shell-interpreter (null refresh))
+      python-tests-shell-interpreter
+    (setq python-tests-shell-interpreter
+          (or (when-let* ((interpreter (getenv "EMACS_PYTHON_INTERPRETER")))
+                (or (executable-find interpreter)
+                    (error "Not found EMACS_PYTHON_INTERPRETER: %s" interpreter)))
+              (cl-some #'executable-find '("python" "python3" "python2"))))))
 
 (ert-deftest python-shell-get-process-name-1 ()
   "Check process name calculation sans `buffer-file-name'."
@@ -3980,13 +3989,13 @@ if x:
 
 (ert-deftest python-shell-make-comint-1 ()
   "Check comint creation for global shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   ;; The interpreter can get killed too quickly to allow it to clean
   ;; up the tempfiles that the default python-shell-setup-codes create,
   ;; so it leaves tempfiles behind, which is a minor irritation.
   (let* ((python-shell-setup-codes nil)
          (python-shell-interpreter
-          (executable-find python-tests-shell-interpreter))
+          (python-tests-get-shell-interpreter))
          (proc-name (python-shell-get-process-name nil))
          (shell-buffer
           (python-tests-with-temp-buffer
@@ -4004,10 +4013,10 @@ if x:
 
 (ert-deftest python-shell-make-comint-2 ()
   "Check comint creation for internal shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((python-shell-setup-codes nil)
          (python-shell-interpreter
-          (executable-find python-tests-shell-interpreter))
+          (python-tests-get-shell-interpreter))
          (proc-name (python-shell-internal-get-process-name))
          (shell-buffer
           (python-tests-with-temp-buffer
@@ -4028,13 +4037,13 @@ if x:
 The command passed to `python-shell-make-comint' as argument must
 locally override global values set in `python-shell-interpreter'
 and `python-shell-interpreter-args' in the new shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((python-shell-setup-codes nil)
          (python-shell-interpreter "interpreter")
          (python-shell-interpreter-args "--some-args")
          (proc-name (python-shell-get-process-name nil))
          (interpreter-override
-          (concat (executable-find python-tests-shell-interpreter) " " "-i"))
+          (concat (python-tests-get-shell-interpreter) " " "-i"))
          (shell-buffer
           (python-tests-with-temp-buffer
            "" (python-shell-make-comint interpreter-override proc-name nil)))
@@ -4047,17 +4056,17 @@ and `python-shell-interpreter-args' in the new shell buffer."
             (should (eq major-mode 'inferior-python-mode))
             (should (file-equal-p
                      python-shell-interpreter
-                     (executable-find python-tests-shell-interpreter)))
+                     (python-tests-get-shell-interpreter)))
             (should (string= python-shell-interpreter-args "-i"))))
       (kill-buffer shell-buffer))))
 
 (ert-deftest python-shell-make-comint-4 ()
   "Check shell calculated prompts regexps are set."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((process-environment process-environment)
          (python-shell-setup-codes nil)
          (python-shell-interpreter
-          (executable-find python-tests-shell-interpreter))
+          (python-tests-get-shell-interpreter))
          (python-shell-interpreter-args "-i")
          (python-shell--prompt-calculated-input-regexp nil)
          (python-shell--prompt-calculated-output-regexp nil)
@@ -4099,12 +4108,12 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-get-process-1 ()
   "Check dedicated shell process preference over global."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-file
       ""
     (let* ((python-shell-setup-codes nil)
            (python-shell-interpreter
-            (executable-find python-tests-shell-interpreter))
+            (python-tests-get-shell-interpreter))
            (global-proc-name (python-shell-get-process-name nil))
            (dedicated-proc-name (python-shell-get-process-name t))
            (global-shell-buffer
@@ -4132,12 +4141,12 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-internal-get-or-create-process-1 ()
   "Check internal shell process creation fallback."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-file
    ""
    (should (not (process-live-p (python-shell-internal-get-process-name))))
    (let* ((python-shell-interpreter
-           (executable-find python-tests-shell-interpreter))
+           (python-tests-get-shell-interpreter))
           (internal-process-name (python-shell-internal-get-process-name))
           (internal-process (python-shell-internal-get-or-create-process))
           (internal-shell-buffer (process-buffer internal-process)))
@@ -4155,7 +4164,7 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-prompt-detect-1 ()
   "Check prompt autodetection."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let ((process-environment process-environment))
     ;; Ensure no startup file is enabled
     (setenv "PYTHONSTARTUP" "")
@@ -4164,7 +4173,7 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-prompt-detect-2 ()
   "Check prompt autodetection with startup file.  Bug#17370."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((process-environment process-environment)
          (startup-code (concat "import sys\n"
                                "sys.ps1 = 'py> '\n"
@@ -4181,7 +4190,7 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-prompt-detect-3 ()
   "Check prompts are not autodetected when feature is disabled."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let ((process-environment process-environment)
         (python-shell-prompt-detect-enabled nil))
     ;; Ensure no startup file is enabled
@@ -4190,7 +4199,7 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-prompt-detect-4 ()
   "Check warning is shown when detection fails."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((process-environment process-environment)
          ;; Trigger failure by removing prompts in the startup file
          (startup-code (concat "import sys\n"
@@ -4211,7 +4220,7 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-prompt-detect-5 ()
   "Check disabled warnings are not shown when detection fails."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((process-environment process-environment)
          (startup-code (concat "import sys\n"
                                "sys.ps1 = ''\n"
@@ -4232,7 +4241,7 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-prompt-detect-6 ()
   "Warnings are not shown when detection is disabled."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((process-environment process-environment)
          (startup-code (concat "import sys\n"
                                "sys.ps1 = ''\n"
@@ -4396,7 +4405,7 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-prompt-set-calculated-regexps-6 ()
   "Check detected prompts are included `regexp-quote'd."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((python-shell-prompt-input-regexps '(""))
          (python-shell-prompt-output-regexps '(""))
          (python-shell-prompt-regexp "")
@@ -4779,7 +4788,7 @@ def foo():
     (should (python-shell-completion-native-interpreter-disabled-p))))
 
 (ert-deftest python-shell-completion-at-point-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    ""
    (python-shell-with-shell-buffer
@@ -4793,7 +4802,7 @@ def foo():
      (should-not (nth 2 (python-shell-completion-at-point))))))
 
 (ert-deftest python-shell-completion-at-point-native-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    ""
    (python-shell-completion-native-turn-on)
@@ -4872,14 +4881,14 @@ def foo():
   "Return Jedi readline setup file if PYTHONSTARTUP is not set."
   (or (getenv "PYTHONSTARTUP")
       (with-temp-buffer
-        (if (eql 0 (call-process python-tests-shell-interpreter
+        (if (eql 0 (call-process (python-tests-get-shell-interpreter)
                                  nil t nil "-m" "jedi" "repl"))
             (string-trim (buffer-string))
           ""))))
 
 (ert-deftest python-shell-completion-at-point-jedi-completer ()
   "Check if Python shell completion works when Jedi completer is used."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (with-environment-variables
       (("PYTHONSTARTUP" (python-tests--pythonstartup-file)))
     (python-tests-with-temp-buffer-with-shell
@@ -4924,7 +4933,7 @@ def foo():
 ;;; Symbol completion
 
 (ert-deftest python-completion-at-point-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -4942,7 +4951,7 @@ import abc
 
 (ert-deftest python-completion-at-point-2 ()
   "Should work regardless of the point in the Shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -4960,7 +4969,7 @@ import abc
 
 (ert-deftest python-completion-at-point-pdb-1 ()
   "Should not complete PDB commands in Python buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import pdb
@@ -4979,7 +4988,7 @@ print('Hello')
 
 (ert-deftest python-completion-at-point-while-running-1 ()
   "Should not try to complete when a program is running in the Shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import time
@@ -4995,7 +5004,7 @@ time.sleep(3)
      (should-not (with-timeout (1 t) (completion-at-point))))))
 
 (ert-deftest python-completion-at-point-native-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -5014,7 +5023,7 @@ import abc
 
 (ert-deftest python-completion-at-point-native-2 ()
   "Should work regardless of the point in the Shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -5032,7 +5041,7 @@ import abc
      (should (completion-at-point)))))
 
 (ert-deftest python-completion-at-point-native-with-ffap-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -5050,7 +5059,7 @@ import abc
      (should (completion-at-point)))))
 
 (ert-deftest python-completion-at-point-native-with-eldoc-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -5077,7 +5086,7 @@ import abc
 ;;; FFAP
 
 (ert-deftest python-ffap-module-path-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -5089,7 +5098,7 @@ import abc
 
 (ert-deftest python-ffap-module-path-while-running-1 ()
   "Should not get module path when a program is running in the Shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -5165,7 +5174,7 @@ some_symbol   some_other_symbol
                     "some_symbol"))))
 
 (ert-deftest python-eldoc--get-doc-at-point-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import time
@@ -5178,7 +5187,7 @@ import time
 
 (ert-deftest python-eldoc--get-doc-at-point-while-running-1 ()
   "Should not get documentation when a program is running in the Shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import time
@@ -7396,7 +7405,7 @@ buffer with overlapping strings."
 ;; interpreter.
 (ert-deftest python-tests--run-python-selects-window ()
   "Test for bug#31398.  See also bug#44421 and bug#52380."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((buffer (process-buffer (run-python nil nil 'show)))
          (window (get-buffer-window buffer)))
     ;; We look at `selected-window' rather than `current-buffer'
@@ -7467,7 +7476,7 @@ buffer with overlapping strings."
                        "W0611: Unused import a.b.c (unused-import)"))))))
 
 (ert-deftest python-test--shell-send-block ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
     "print('current 0')
 for x in range(1,3):
-- 
2.20.5


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  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-18 22:20 ` Stefan Kangas
  2024-05-26 10:52 ` Mattias Engdegård
  2 siblings, 1 reply; 49+ messages in thread
From: Eli Zaretskii @ 2024-05-11  9:05 UTC (permalink / raw)
  To: Lin Sun, kobarity; +Cc: 70815

> From: Lin Sun <sunlin7.mail@gmail.com>
> Date: Tue, 7 May 2024 06:53:05 +0000
> 
> The python-tests.el will fail on finding interpreter "python" for
> there is no "python"  on CentOS8, Ubuntu 20.04,  only "python3" exists
> after installation.

Thanks, I have some comments, and maybe kobarity will have as well.

> +(defun python-tests-get-shell-interpreter (&optional refresh)

AFAICT, this function is never called with the optional REFRESH
argument non-nil, so why do we need it?

> +  (if (and python-tests-shell-interpreter (null refresh))
> +      python-tests-shell-interpreter
> +    (setq python-tests-shell-interpreter
> +          (or (when-let* ((interpreter (getenv "EMACS_PYTHON_INTERPRETER")))
> +                (or (executable-find interpreter)
> +                    (error "Not found EMACS_PYTHON_INTERPRETER: %s" interpreter)))

Is it indeed useful to error out here?  Should we instead fall back to
the default list, '("python" "python3" "python2") ?

> +              (cl-some #'executable-find '("python" "python3" "python2"))))))

cl-some is in cl-extra, so the test should require it.





^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-11  9:05 ` Eli Zaretskii
@ 2024-05-11 13:37   ` kobarity
  2024-05-11 14:27     ` Lin Sun
  0 siblings, 1 reply; 49+ messages in thread
From: kobarity @ 2024-05-11 13:37 UTC (permalink / raw)
  To: Lin Sun, Eli Zaretskii; +Cc: 70815


Eli Zaretskii wrote:
> 
> > From: Lin Sun <sunlin7.mail@gmail.com>
> > Date: Tue, 7 May 2024 06:53:05 +0000
> > 
> > The python-tests.el will fail on finding interpreter "python" for
> > there is no "python"  on CentOS8, Ubuntu 20.04,  only "python3" exists
> > after installation.
> 
> Thanks, I have some comments, and maybe kobarity will have as well.

Hi Lin,

Please correct the typo "Enahnce" in the title.

I think the summary line of this commit should not begin with a
semicolon.  CONTRIBUTE says:

  If the summary line starts with a semicolon and a space "; ", the
  commit message will be skipped and not added to the generated
  ChangeLog file.  Use this for minor commits that do not need to be
  mentioned in the ChangeLog file, such as changes in etc/NEWS, typo
  fixes, etc.

When revising the patch, please include the bug number.  CONTRIBUTE
says:

- The commit message should contain "Bug#NNNNN" if it is related to
  bug number NNNNN in the debbugs database.  This string is often
  parenthesized, as in "(Bug#19003)".

python-tests-get-shell-interpreter should have an docstring.  This can
be checked with checkdoc.  CONTRIBUTE says:

  Use 'checkdoc' to check for documentation errors before submitting a
  patch.

I recommend to use Flymake or Flycheck.  There are many violations in
python-tests.el, but I think it is better for new patches to follow
this rule.

when-let* used in python-tests-get-shell-interpreter could be replaced
with when-let.





^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-11 13:37   ` kobarity
@ 2024-05-11 14:27     ` Lin Sun
  2024-05-12  2:06       ` kobarity
  0 siblings, 1 reply; 49+ messages in thread
From: Lin Sun @ 2024-05-11 14:27 UTC (permalink / raw)
  To: kobarity; +Cc: Eli Zaretskii, 70815

[-- Attachment #1: Type: text/plain, Size: 1720 bytes --]

On Sat, May 11, 2024, 06:37 kobarity <kobarity@gmail.com> wrote:

>
> Eli Zaretskii wrote:
> >
> > > From: Lin Sun <sunlin7.mail@gmail.com>
> > > Date: Tue, 7 May 2024 06:53:05 +0000
> > >
> > > The python-tests.el will fail on finding interpreter "python" for
> > > there is no "python"  on CentOS8, Ubuntu 20.04,  only "python3" exists
> > > after installation.
> >
> > Thanks, I have some comments, and maybe kobarity will have as well.
>
> Hi Lin,
>
> Please correct the typo "Enahnce" in the title.
>
> I think the summary line of this commit should not begin with a
> semicolon.  CONTRIBUTE says:
>
>   If the summary line starts with a semicolon and a space "; ", the
>   commit message will be skipped and not added to the generated
>   ChangeLog file.  Use this for minor commits that do not need to be
>   mentioned in the ChangeLog file, such as changes in etc/NEWS, typo
>   fixes, etc.
>
> When revising the patch, please include the bug number.  CONTRIBUTE
> says:
>
> - The commit message should contain "Bug#NNNNN" if it is related to
>   bug number NNNNN in the debbugs database.  This string is often
>   parenthesized, as in "(Bug#19003)".
>
> python-tests-get-shell-interpreter should have an docstring.  This can
> be checked with checkdoc.  CONTRIBUTE says:
>
>   Use 'checkdoc' to check for documentation errors before submitting a
>   patch.
>
> I recommend to use Flymake or Flycheck.  There are many violations in
> python-tests.el, but I think it is better for new patches to follow
> this rule.
>
> when-let* used in python-tests-get-shell-interpreter could be replaced
> with when-let.
>

Hi Eli, kobarit,
I'm trying change the code to follow your comments, will update later,
thank you!

>

[-- Attachment #2: Type: text/html, Size: 2593 bytes --]

^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-11 14:27     ` Lin Sun
@ 2024-05-12  2:06       ` kobarity
  0 siblings, 0 replies; 49+ messages in thread
From: kobarity @ 2024-05-12  2:06 UTC (permalink / raw)
  To: Lin Sun; +Cc: Eli Zaretskii, 70815


Lin Sun wrote:
> On Sat, May 11, 2024, 06:37 kobarity <kobarity@gmail.com> wrote:
> 
>  Eli Zaretskii wrote:
>  > 
>  > > From: Lin Sun <sunlin7.mail@gmail.com>
>  > > Date: Tue, 7 May 2024 06:53:05 +0000
>  > > 
>  > > The python-tests.el will fail on finding interpreter "python" for
>  > > there is no "python"  on CentOS8, Ubuntu 20.04,  only "python3" exists
>  > > after installation.
>  > 
>  > Thanks, I have some comments, and maybe kobarity will have as well.
> 
>  Hi Lin,
> 
>  Please correct the typo "Enahnce" in the title.
> 
>  I think the summary line of this commit should not begin with a
>  semicolon.  CONTRIBUTE says:
> 
>    If the summary line starts with a semicolon and a space "; ", the
>    commit message will be skipped and not added to the generated
>    ChangeLog file.  Use this for minor commits that do not need to be
>    mentioned in the ChangeLog file, such as changes in etc/NEWS, typo
>    fixes, etc.
> 
>  When revising the patch, please include the bug number.  CONTRIBUTE
>  says:
> 
>  - The commit message should contain "Bug#NNNNN" if it is related to
>    bug number NNNNN in the debbugs database.  This string is often
>    parenthesized, as in "(Bug#19003)".
> 
>  python-tests-get-shell-interpreter should have an docstring.  This can
>  be checked with checkdoc.  CONTRIBUTE says:
> 
>    Use 'checkdoc' to check for documentation errors before submitting a
>    patch.
> 
>  I recommend to use Flymake or Flycheck.  There are many violations in
>  python-tests.el, but I think it is better for new patches to follow
>  this rule.
> 
>  when-let* used in python-tests-get-shell-interpreter could be replaced
>  with when-let.
> 
> Hi Eli, kobarit,
> I'm trying change the code to follow your comments, will update later, thank you!

Hi Lin,
I noticed another issue.  If there is only python2 in the PATH and no
python or python3, some tests will fail.

20 unexpected results:
   FAILED  python-completion-at-point-1
   FAILED  python-completion-at-point-2
   FAILED  python-completion-at-point-native-1
   FAILED  python-completion-at-point-native-2
   FAILED  python-completion-at-point-native-with-eldoc-1
   FAILED  python-completion-at-point-native-with-ffap-1
   FAILED  python-completion-at-point-pdb-1
   FAILED  python-completion-at-point-while-running-1
   FAILED  python-eldoc--get-doc-at-point-1
   FAILED  python-eldoc--get-doc-at-point-while-running-1
   FAILED  python-ffap-module-path-1
   FAILED  python-ffap-module-path-while-running-1
   FAILED  python-shell-completion-at-point-1
   FAILED  python-shell-completion-at-point-jedi-completer
   FAILED  python-shell-completion-at-point-native-1
   FAILED  python-shell-prompt-detect-1
   FAILED  python-shell-prompt-detect-2
   FAILED  python-shell-prompt-set-calculated-regexps-6
   FAILED  python-test--shell-send-block
   FAILED  python-tests--run-python-selects-window

This is because `python-shell-interpreter' is not let-bound and is set
to "python3".

One way to resolve these would be to provide a thin wrapper like
`python-tests-shell-with-shell-buffer' and bind
`python-shell-interpreter' to (python-tests-get-shell-interpreter).

Current ERTs seem to support both Python 2/3, but it may become
necessary to write an ERT that supports only Python 3.  It would be
nice if the author of the ERT could specify an interpreter, but there
may be no need to prepare one now.





^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  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-18 22:20 ` Stefan Kangas
  2024-05-19  5:54   ` Eli Zaretskii
  2024-05-26 10:52 ` Mattias Engdegård
  2 siblings, 1 reply; 49+ messages in thread
From: Stefan Kangas @ 2024-05-18 22:20 UTC (permalink / raw)
  To: Lin Sun, 70815; +Cc: kobarity

Lin Sun <sunlin7.mail@gmail.com> writes:

> From 49dfcecbbffaf15aa0414d15f22d8bcbf768ebb3 Mon Sep 17 00:00:00 2001
> From: Lin Sun <sunlin7@hotmail.com>
> Date: Fri, 3 May 2024 06:52:22 +0000
> Subject: [PATCH] ; Enahnce python-tests.el to adapt different python
>  interpreters
>
> * test/lisp/progmodes/python-tests.el
>   (python-tests-get-shell-interpreter): New function to get python
>   interpreter for testing.
> ---
>  test/lisp/progmodes/python-tests.el | 87 ++++++++++++++++-------------
>  1 file changed, 48 insertions(+), 39 deletions(-)
>
> diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
> index f50797953c3..6da149925ec 100644
> --- a/test/lisp/progmodes/python-tests.el
> +++ b/test/lisp/progmodes/python-tests.el
> @@ -3718,7 +3718,16 @@ if x:
>  \f
>  ;;; Shell integration
>
> -(defvar python-tests-shell-interpreter "python")
> +(defvar python-tests-shell-interpreter nil)
> +
> +(defun python-tests-get-shell-interpreter (&optional refresh)
> +  (if (and python-tests-shell-interpreter (null refresh))
> +      python-tests-shell-interpreter
> +    (setq python-tests-shell-interpreter
> +          (or (when-let* ((interpreter (getenv "EMACS_PYTHON_INTERPRETER")))
> +                (or (executable-find interpreter)
> +                    (error "Not found EMACS_PYTHON_INTERPRETER: %s" interpreter)))
> +              (cl-some #'executable-find '("python" "python3" "python2"))))))

It makes sense to look for "python3", but is it really useful to look
for "python2" at this point?





^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-18 22:20 ` Stefan Kangas
@ 2024-05-19  5:54   ` Eli Zaretskii
  2024-05-20  0:08     ` Lin Sun
  0 siblings, 1 reply; 49+ messages in thread
From: Eli Zaretskii @ 2024-05-19  5:54 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: kobarity, sunlin7.mail, 70815

> 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.





^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-19  5:54   ` Eli Zaretskii
@ 2024-05-20  0:08     ` Lin Sun
  2024-05-20 15:52       ` kobarity
  0 siblings, 1 reply; 49+ messages in thread
From: Lin Sun @ 2024-05-20  0:08 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: kobarity, Stefan Kangas, 70815

[-- Attachment #1: Type: text/plain, Size: 260 bytes --]

Hi,
I attached the latest patch, hope it resolved all your concerns.
> 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.

[-- Attachment #2: 0001-Enahnce-python-tests.el-to-adapt-different-python-in.patch --]
[-- Type: text/x-patch, Size: 16203 bytes --]

From 69c63565e2615a73df8cc7f0afd7346b5f0b801e Mon Sep 17 00:00:00 2001
From: Lin Sun <sunlin7@hotmail.com>
Date: Fri, 3 May 2024 06:52:22 +0000
Subject: [PATCH] Enahnce python-tests.el to adapt different python
 interpreters (bug#70815)

* test/lisp/progmodes/python-tests.el
  (python-tests-get-shell-interpreter): New function to get python
  interpreter for testing; and also introduce new env variable
  EMACS_PYTHON_INTERPRETER to support customer python interpreter.
---
 test/lisp/progmodes/python-tests.el | 91 ++++++++++++++++-------------
 1 file changed, 52 insertions(+), 39 deletions(-)

diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
index f50797953c3..809258e6f66 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -21,6 +21,7 @@
 
 ;;; Code:
 
+(require 'cl-extra)
 (require 'ert)
 (require 'ert-x)
 (require 'python)
@@ -3718,7 +3719,19 @@ if x:
 \f
 ;;; Shell integration
 
-(defvar python-tests-shell-interpreter "python")
+(defvar python-tests-shell-interpreter nil)
+
+(defun python-tests-get-shell-interpreter ()
+  "Get the shell interpreter.
+If env string EMACS_PYTHON_INTERPRETER exists, use it as prefered one."
+  (if python-tests-shell-interpreter
+      python-tests-shell-interpreter
+    (setq python-tests-shell-interpreter
+          (or (when-let ((interpreter (getenv "EMACS_PYTHON_INTERPRETER")))
+                (or (executable-find interpreter)
+                    (error "Can't found EMACS_PYTHON_INTERPRETER(%s) in path"
+                           interpreter)))
+              (cl-some #'executable-find '("python" "python3" "python2"))))))
 
 (ert-deftest python-shell-get-process-name-1 ()
   "Check process name calculation sans `buffer-file-name'."
@@ -3980,13 +3993,13 @@ if x:
 
 (ert-deftest python-shell-make-comint-1 ()
   "Check comint creation for global shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   ;; The interpreter can get killed too quickly to allow it to clean
   ;; up the tempfiles that the default python-shell-setup-codes create,
   ;; so it leaves tempfiles behind, which is a minor irritation.
   (let* ((python-shell-setup-codes nil)
          (python-shell-interpreter
-          (executable-find python-tests-shell-interpreter))
+          (python-tests-get-shell-interpreter))
          (proc-name (python-shell-get-process-name nil))
          (shell-buffer
           (python-tests-with-temp-buffer
@@ -4004,10 +4017,10 @@ if x:
 
 (ert-deftest python-shell-make-comint-2 ()
   "Check comint creation for internal shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((python-shell-setup-codes nil)
          (python-shell-interpreter
-          (executable-find python-tests-shell-interpreter))
+          (python-tests-get-shell-interpreter))
          (proc-name (python-shell-internal-get-process-name))
          (shell-buffer
           (python-tests-with-temp-buffer
@@ -4028,13 +4041,13 @@ if x:
 The command passed to `python-shell-make-comint' as argument must
 locally override global values set in `python-shell-interpreter'
 and `python-shell-interpreter-args' in the new shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((python-shell-setup-codes nil)
          (python-shell-interpreter "interpreter")
          (python-shell-interpreter-args "--some-args")
          (proc-name (python-shell-get-process-name nil))
          (interpreter-override
-          (concat (executable-find python-tests-shell-interpreter) " " "-i"))
+          (concat (python-tests-get-shell-interpreter) " " "-i"))
          (shell-buffer
           (python-tests-with-temp-buffer
            "" (python-shell-make-comint interpreter-override proc-name nil)))
@@ -4047,17 +4060,17 @@ and `python-shell-interpreter-args' in the new shell buffer."
             (should (eq major-mode 'inferior-python-mode))
             (should (file-equal-p
                      python-shell-interpreter
-                     (executable-find python-tests-shell-interpreter)))
+                     (python-tests-get-shell-interpreter)))
             (should (string= python-shell-interpreter-args "-i"))))
       (kill-buffer shell-buffer))))
 
 (ert-deftest python-shell-make-comint-4 ()
   "Check shell calculated prompts regexps are set."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((process-environment process-environment)
          (python-shell-setup-codes nil)
          (python-shell-interpreter
-          (executable-find python-tests-shell-interpreter))
+          (python-tests-get-shell-interpreter))
          (python-shell-interpreter-args "-i")
          (python-shell--prompt-calculated-input-regexp nil)
          (python-shell--prompt-calculated-output-regexp nil)
@@ -4099,12 +4112,12 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-get-process-1 ()
   "Check dedicated shell process preference over global."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-file
       ""
     (let* ((python-shell-setup-codes nil)
            (python-shell-interpreter
-            (executable-find python-tests-shell-interpreter))
+            (python-tests-get-shell-interpreter))
            (global-proc-name (python-shell-get-process-name nil))
            (dedicated-proc-name (python-shell-get-process-name t))
            (global-shell-buffer
@@ -4132,12 +4145,12 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-internal-get-or-create-process-1 ()
   "Check internal shell process creation fallback."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-file
    ""
    (should (not (process-live-p (python-shell-internal-get-process-name))))
    (let* ((python-shell-interpreter
-           (executable-find python-tests-shell-interpreter))
+           (python-tests-get-shell-interpreter))
           (internal-process-name (python-shell-internal-get-process-name))
           (internal-process (python-shell-internal-get-or-create-process))
           (internal-shell-buffer (process-buffer internal-process)))
@@ -4155,7 +4168,7 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-prompt-detect-1 ()
   "Check prompt autodetection."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let ((process-environment process-environment))
     ;; Ensure no startup file is enabled
     (setenv "PYTHONSTARTUP" "")
@@ -4164,7 +4177,7 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-prompt-detect-2 ()
   "Check prompt autodetection with startup file.  Bug#17370."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((process-environment process-environment)
          (startup-code (concat "import sys\n"
                                "sys.ps1 = 'py> '\n"
@@ -4181,7 +4194,7 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-prompt-detect-3 ()
   "Check prompts are not autodetected when feature is disabled."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let ((process-environment process-environment)
         (python-shell-prompt-detect-enabled nil))
     ;; Ensure no startup file is enabled
@@ -4190,7 +4203,7 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-prompt-detect-4 ()
   "Check warning is shown when detection fails."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((process-environment process-environment)
          ;; Trigger failure by removing prompts in the startup file
          (startup-code (concat "import sys\n"
@@ -4211,7 +4224,7 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-prompt-detect-5 ()
   "Check disabled warnings are not shown when detection fails."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((process-environment process-environment)
          (startup-code (concat "import sys\n"
                                "sys.ps1 = ''\n"
@@ -4232,7 +4245,7 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-prompt-detect-6 ()
   "Warnings are not shown when detection is disabled."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((process-environment process-environment)
          (startup-code (concat "import sys\n"
                                "sys.ps1 = ''\n"
@@ -4396,7 +4409,7 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-prompt-set-calculated-regexps-6 ()
   "Check detected prompts are included `regexp-quote'd."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((python-shell-prompt-input-regexps '(""))
          (python-shell-prompt-output-regexps '(""))
          (python-shell-prompt-regexp "")
@@ -4779,7 +4792,7 @@ def foo():
     (should (python-shell-completion-native-interpreter-disabled-p))))
 
 (ert-deftest python-shell-completion-at-point-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    ""
    (python-shell-with-shell-buffer
@@ -4793,7 +4806,7 @@ def foo():
      (should-not (nth 2 (python-shell-completion-at-point))))))
 
 (ert-deftest python-shell-completion-at-point-native-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    ""
    (python-shell-completion-native-turn-on)
@@ -4872,14 +4885,14 @@ def foo():
   "Return Jedi readline setup file if PYTHONSTARTUP is not set."
   (or (getenv "PYTHONSTARTUP")
       (with-temp-buffer
-        (if (eql 0 (call-process python-tests-shell-interpreter
+        (if (eql 0 (call-process (python-tests-get-shell-interpreter)
                                  nil t nil "-m" "jedi" "repl"))
             (string-trim (buffer-string))
           ""))))
 
 (ert-deftest python-shell-completion-at-point-jedi-completer ()
   "Check if Python shell completion works when Jedi completer is used."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (with-environment-variables
       (("PYTHONSTARTUP" (python-tests--pythonstartup-file)))
     (python-tests-with-temp-buffer-with-shell
@@ -4924,7 +4937,7 @@ def foo():
 ;;; Symbol completion
 
 (ert-deftest python-completion-at-point-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -4942,7 +4955,7 @@ import abc
 
 (ert-deftest python-completion-at-point-2 ()
   "Should work regardless of the point in the Shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -4960,7 +4973,7 @@ import abc
 
 (ert-deftest python-completion-at-point-pdb-1 ()
   "Should not complete PDB commands in Python buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import pdb
@@ -4979,7 +4992,7 @@ print('Hello')
 
 (ert-deftest python-completion-at-point-while-running-1 ()
   "Should not try to complete when a program is running in the Shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import time
@@ -4995,7 +5008,7 @@ time.sleep(3)
      (should-not (with-timeout (1 t) (completion-at-point))))))
 
 (ert-deftest python-completion-at-point-native-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -5014,7 +5027,7 @@ import abc
 
 (ert-deftest python-completion-at-point-native-2 ()
   "Should work regardless of the point in the Shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -5032,7 +5045,7 @@ import abc
      (should (completion-at-point)))))
 
 (ert-deftest python-completion-at-point-native-with-ffap-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -5050,7 +5063,7 @@ import abc
      (should (completion-at-point)))))
 
 (ert-deftest python-completion-at-point-native-with-eldoc-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -5077,7 +5090,7 @@ import abc
 ;;; FFAP
 
 (ert-deftest python-ffap-module-path-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -5089,7 +5102,7 @@ import abc
 
 (ert-deftest python-ffap-module-path-while-running-1 ()
   "Should not get module path when a program is running in the Shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -5165,7 +5178,7 @@ some_symbol   some_other_symbol
                     "some_symbol"))))
 
 (ert-deftest python-eldoc--get-doc-at-point-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import time
@@ -5178,7 +5191,7 @@ import time
 
 (ert-deftest python-eldoc--get-doc-at-point-while-running-1 ()
   "Should not get documentation when a program is running in the Shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import time
@@ -7396,7 +7409,7 @@ buffer with overlapping strings."
 ;; interpreter.
 (ert-deftest python-tests--run-python-selects-window ()
   "Test for bug#31398.  See also bug#44421 and bug#52380."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((buffer (process-buffer (run-python nil nil 'show)))
          (window (get-buffer-window buffer)))
     ;; We look at `selected-window' rather than `current-buffer'
@@ -7467,7 +7480,7 @@ buffer with overlapping strings."
                        "W0611: Unused import a.b.c (unused-import)"))))))
 
 (ert-deftest python-test--shell-send-block ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
     "print('current 0')
 for x in range(1,3):
-- 
2.20.5


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-20  0:08     ` Lin Sun
@ 2024-05-20 15:52       ` kobarity
  2024-05-20 17:51         ` Lin Sun
  0 siblings, 1 reply; 49+ messages in thread
From: kobarity @ 2024-05-20 15:52 UTC (permalink / raw)
  To: Lin Sun; +Cc: Eli Zaretskii, Stefan Kangas, 70815

[-- 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

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-20 15:52       ` kobarity
@ 2024-05-20 17:51         ` Lin Sun
  2024-05-21 14:04           ` kobarity
  0 siblings, 1 reply; 49+ messages in thread
From: Lin Sun @ 2024-05-20 17:51 UTC (permalink / raw)
  To: kobarity; +Cc: Eli Zaretskii, Stefan Kangas, 70815

[-- Attachment #1: Type: text/plain, Size: 1998 bytes --]

On Mon, May 20, 2024 at 3:53 PM kobarity <kobarity@gmail.com> wrote:
> 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.

Thank you for the comments, now get your points and agree with you.
I merged your patch together, also corrected the typo in the commit message.
Please help review the attached patch. Thank you !

[-- Attachment #2: 0001-Enhance-python-tests.el-to-adapt-different-python-in.patch --]
[-- Type: text/x-patch, Size: 17932 bytes --]

From fadff4b761043f26f8a54970358c10a301bad5bd Mon Sep 17 00:00:00 2001
From: Lin Sun <sunlin7@hotmail.com>
Date: Fri, 3 May 2024 06:52:22 +0000
Subject: [PATCH] Enhance python-tests.el to adapt different python
 interpreters (bug#70815)

* test/lisp/progmodes/python-tests.el
  (python-tests-get-shell-interpreter): New function to get python
  interpreter for testing; and also introduce new env variable
  EMACS_PYTHON_INTERPRETER to support customer python interpreter.

Co-authored-by: kobarity <kobarity@gmail.com>
---
 test/lisp/progmodes/python-tests.el | 102 ++++++++++++++++------------
 1 file changed, 60 insertions(+), 42 deletions(-)

diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
index f50797953c3..bec989520bd 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -21,6 +21,7 @@
 
 ;;; Code:
 
+(require 'cl-extra)
 (require 'ert)
 (require 'ert-x)
 (require 'python)
@@ -58,7 +59,8 @@ turned off.  Shell buffer will be killed on exit."
   (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
@@ -3718,7 +3720,19 @@ if x:
 \f
 ;;; Shell integration
 
-(defvar python-tests-shell-interpreter "python")
+(defvar python-tests-shell-interpreter nil)
+
+(defun python-tests-get-shell-interpreter ()
+  "Get the shell interpreter.
+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
+          (or (when-let ((interpreter (getenv "EMACS_PYTHON_INTERPRETER")))
+                (or (executable-find interpreter)
+                    (error "Can't found EMACS_PYTHON_INTERPRETER(%s) in path"
+                           interpreter)))
+              (cl-some #'executable-find '("python" "python3" "python2"))))))
 
 (ert-deftest python-shell-get-process-name-1 ()
   "Check process name calculation sans `buffer-file-name'."
@@ -3980,13 +3994,13 @@ if x:
 
 (ert-deftest python-shell-make-comint-1 ()
   "Check comint creation for global shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   ;; The interpreter can get killed too quickly to allow it to clean
   ;; up the tempfiles that the default python-shell-setup-codes create,
   ;; so it leaves tempfiles behind, which is a minor irritation.
   (let* ((python-shell-setup-codes nil)
          (python-shell-interpreter
-          (executable-find python-tests-shell-interpreter))
+          (python-tests-get-shell-interpreter))
          (proc-name (python-shell-get-process-name nil))
          (shell-buffer
           (python-tests-with-temp-buffer
@@ -4004,10 +4018,10 @@ if x:
 
 (ert-deftest python-shell-make-comint-2 ()
   "Check comint creation for internal shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((python-shell-setup-codes nil)
          (python-shell-interpreter
-          (executable-find python-tests-shell-interpreter))
+          (python-tests-get-shell-interpreter))
          (proc-name (python-shell-internal-get-process-name))
          (shell-buffer
           (python-tests-with-temp-buffer
@@ -4028,13 +4042,13 @@ if x:
 The command passed to `python-shell-make-comint' as argument must
 locally override global values set in `python-shell-interpreter'
 and `python-shell-interpreter-args' in the new shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((python-shell-setup-codes nil)
          (python-shell-interpreter "interpreter")
          (python-shell-interpreter-args "--some-args")
          (proc-name (python-shell-get-process-name nil))
          (interpreter-override
-          (concat (executable-find python-tests-shell-interpreter) " " "-i"))
+          (concat (python-tests-get-shell-interpreter) " " "-i"))
          (shell-buffer
           (python-tests-with-temp-buffer
            "" (python-shell-make-comint interpreter-override proc-name nil)))
@@ -4047,17 +4061,17 @@ and `python-shell-interpreter-args' in the new shell buffer."
             (should (eq major-mode 'inferior-python-mode))
             (should (file-equal-p
                      python-shell-interpreter
-                     (executable-find python-tests-shell-interpreter)))
+                     (python-tests-get-shell-interpreter)))
             (should (string= python-shell-interpreter-args "-i"))))
       (kill-buffer shell-buffer))))
 
 (ert-deftest python-shell-make-comint-4 ()
   "Check shell calculated prompts regexps are set."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((process-environment process-environment)
          (python-shell-setup-codes nil)
          (python-shell-interpreter
-          (executable-find python-tests-shell-interpreter))
+          (python-tests-get-shell-interpreter))
          (python-shell-interpreter-args "-i")
          (python-shell--prompt-calculated-input-regexp nil)
          (python-shell--prompt-calculated-output-regexp nil)
@@ -4099,12 +4113,12 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-get-process-1 ()
   "Check dedicated shell process preference over global."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-file
       ""
     (let* ((python-shell-setup-codes nil)
            (python-shell-interpreter
-            (executable-find python-tests-shell-interpreter))
+            (python-tests-get-shell-interpreter))
            (global-proc-name (python-shell-get-process-name nil))
            (dedicated-proc-name (python-shell-get-process-name t))
            (global-shell-buffer
@@ -4132,12 +4146,12 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-internal-get-or-create-process-1 ()
   "Check internal shell process creation fallback."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-file
    ""
    (should (not (process-live-p (python-shell-internal-get-process-name))))
    (let* ((python-shell-interpreter
-           (executable-find python-tests-shell-interpreter))
+           (python-tests-get-shell-interpreter))
           (internal-process-name (python-shell-internal-get-process-name))
           (internal-process (python-shell-internal-get-or-create-process))
           (internal-shell-buffer (process-buffer internal-process)))
@@ -4155,8 +4169,9 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-prompt-detect-1 ()
   "Check prompt autodetection."
-  (skip-unless (executable-find python-tests-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)
@@ -4164,13 +4179,14 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-prompt-detect-2 ()
   "Check prompt autodetection with startup file.  Bug#17370."
-  (skip-unless (executable-find python-tests-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
@@ -4181,7 +4197,7 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-prompt-detect-3 ()
   "Check prompts are not autodetected when feature is disabled."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let ((process-environment process-environment)
         (python-shell-prompt-detect-enabled nil))
     ;; Ensure no startup file is enabled
@@ -4190,7 +4206,7 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-prompt-detect-4 ()
   "Check warning is shown when detection fails."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((process-environment process-environment)
          ;; Trigger failure by removing prompts in the startup file
          (startup-code (concat "import sys\n"
@@ -4211,7 +4227,7 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-prompt-detect-5 ()
   "Check disabled warnings are not shown when detection fails."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((process-environment process-environment)
          (startup-code (concat "import sys\n"
                                "sys.ps1 = ''\n"
@@ -4232,7 +4248,7 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-prompt-detect-6 ()
   "Warnings are not shown when detection is disabled."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((process-environment process-environment)
          (startup-code (concat "import sys\n"
                                "sys.ps1 = ''\n"
@@ -4396,7 +4412,7 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-prompt-set-calculated-regexps-6 ()
   "Check detected prompts are included `regexp-quote'd."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((python-shell-prompt-input-regexps '(""))
          (python-shell-prompt-output-regexps '(""))
          (python-shell-prompt-regexp "")
@@ -4406,6 +4422,7 @@ and `python-shell-interpreter-args' in the new shell buffer."
          (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"
@@ -4779,7 +4796,7 @@ def foo():
     (should (python-shell-completion-native-interpreter-disabled-p))))
 
 (ert-deftest python-shell-completion-at-point-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    ""
    (python-shell-with-shell-buffer
@@ -4793,7 +4810,7 @@ def foo():
      (should-not (nth 2 (python-shell-completion-at-point))))))
 
 (ert-deftest python-shell-completion-at-point-native-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    ""
    (python-shell-completion-native-turn-on)
@@ -4872,14 +4889,14 @@ def foo():
   "Return Jedi readline setup file if PYTHONSTARTUP is not set."
   (or (getenv "PYTHONSTARTUP")
       (with-temp-buffer
-        (if (eql 0 (call-process python-tests-shell-interpreter
+        (if (eql 0 (call-process (python-tests-get-shell-interpreter)
                                  nil t nil "-m" "jedi" "repl"))
             (string-trim (buffer-string))
           ""))))
 
 (ert-deftest python-shell-completion-at-point-jedi-completer ()
   "Check if Python shell completion works when Jedi completer is used."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (with-environment-variables
       (("PYTHONSTARTUP" (python-tests--pythonstartup-file)))
     (python-tests-with-temp-buffer-with-shell
@@ -4924,7 +4941,7 @@ def foo():
 ;;; Symbol completion
 
 (ert-deftest python-completion-at-point-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -4942,7 +4959,7 @@ import abc
 
 (ert-deftest python-completion-at-point-2 ()
   "Should work regardless of the point in the Shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -4960,7 +4977,7 @@ import abc
 
 (ert-deftest python-completion-at-point-pdb-1 ()
   "Should not complete PDB commands in Python buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import pdb
@@ -4979,7 +4996,7 @@ print('Hello')
 
 (ert-deftest python-completion-at-point-while-running-1 ()
   "Should not try to complete when a program is running in the Shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import time
@@ -4995,7 +5012,7 @@ time.sleep(3)
      (should-not (with-timeout (1 t) (completion-at-point))))))
 
 (ert-deftest python-completion-at-point-native-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -5014,7 +5031,7 @@ import abc
 
 (ert-deftest python-completion-at-point-native-2 ()
   "Should work regardless of the point in the Shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -5032,7 +5049,7 @@ import abc
      (should (completion-at-point)))))
 
 (ert-deftest python-completion-at-point-native-with-ffap-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -5050,7 +5067,7 @@ import abc
      (should (completion-at-point)))))
 
 (ert-deftest python-completion-at-point-native-with-eldoc-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -5077,7 +5094,7 @@ import abc
 ;;; FFAP
 
 (ert-deftest python-ffap-module-path-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -5089,7 +5106,7 @@ import abc
 
 (ert-deftest python-ffap-module-path-while-running-1 ()
   "Should not get module path when a program is running in the Shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -5165,7 +5182,7 @@ some_symbol   some_other_symbol
                     "some_symbol"))))
 
 (ert-deftest python-eldoc--get-doc-at-point-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import time
@@ -5178,7 +5195,7 @@ import time
 
 (ert-deftest python-eldoc--get-doc-at-point-while-running-1 ()
   "Should not get documentation when a program is running in the Shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import time
@@ -7396,8 +7413,9 @@ buffer with overlapping strings."
 ;; interpreter.
 (ert-deftest python-tests--run-python-selects-window ()
   "Test for bug#31398.  See also bug#44421 and bug#52380."
-  (skip-unless (executable-find python-tests-shell-interpreter))
-  (let* ((buffer (process-buffer (run-python nil nil 'show)))
+  (skip-unless (python-tests-get-shell-interpreter))
+  (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
@@ -7467,7 +7485,7 @@ buffer with overlapping strings."
                        "W0611: Unused import a.b.c (unused-import)"))))))
 
 (ert-deftest python-test--shell-send-block ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
     "print('current 0')
 for x in range(1,3):
-- 
2.20.5


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-20 17:51         ` Lin Sun
@ 2024-05-21 14:04           ` kobarity
  2024-05-21 15:34             ` Lin Sun
  0 siblings, 1 reply; 49+ messages in thread
From: kobarity @ 2024-05-21 14:04 UTC (permalink / raw)
  To: Lin Sun; +Cc: Eli Zaretskii, Stefan Kangas, 70815

[-- Attachment #1: Type: text/plain, Size: 2321 bytes --]


Lin Sun wrote:
> On Mon, May 20, 2024 at 3:53 PM kobarity <kobarity@gmail.com> wrote:
> > 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.
> 
> Thank you for the comments, now get your points and agree with you.
> I merged your patch together, also corrected the typo in the commit message.
> Please help review the attached patch. Thank you !

Sorry, there was a problem in my diff.  Two tests fail when
EMACS_PYTHON_INTERPRETER is not found.  Please apply the attached
diff.  It also includes a suggestion for improving the error message.
Please consider.

[-- Attachment #2: fix-70815-2.diff --]
[-- Type: application/octet-stream, Size: 1960 bytes --]

diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
index fa8fa74fa88..b19c5c31f16 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -3750,7 +3750,7 @@ python-tests-get-shell-interpreter
     (setq python-tests-shell-interpreter
           (or (when-let ((interpreter (getenv "EMACS_PYTHON_INTERPRETER")))
                 (or (executable-find interpreter)
-                    (error "Can't found EMACS_PYTHON_INTERPRETER(%s) in path"
+                    (error "Couldn't find EMACS_PYTHON_INTERPRETER(%s) in path"
                            interpreter)))
               (cl-some #'executable-find '("python" "python3" "python2"))))))
 
@@ -4189,9 +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)
         (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)
@@ -4199,6 +4199,7 @@ 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"
@@ -4206,7 +4207,6 @@ python-shell-prompt-detect-2
                                "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

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-21 14:04           ` kobarity
@ 2024-05-21 15:34             ` Lin Sun
  2024-05-22 14:38               ` kobarity
  0 siblings, 1 reply; 49+ messages in thread
From: Lin Sun @ 2024-05-21 15:34 UTC (permalink / raw)
  To: kobarity; +Cc: Eli Zaretskii, Stefan Kangas, 70815

[-- Attachment #1: Type: text/plain, Size: 2630 bytes --]

On Tue, May 21, 2024 at 2:04 PM kobarity <kobarity@gmail.com> wrote:
>
>
> Lin Sun wrote:
> > On Mon, May 20, 2024 at 3:53 PM kobarity <kobarity@gmail.com> wrote:
> > > 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.
> >
> > Thank you for the comments, now get your points and agree with you.
> > I merged your patch together, also corrected the typo in the commit message.
> > Please help review the attached patch. Thank you !
>
> Sorry, there was a problem in my diff.  Two tests fail when
> EMACS_PYTHON_INTERPRETER is not found.  Please apply the attached
> diff.  It also includes a suggestion for improving the error message.
> Please consider.

Merged your changes and tested on my local (with python/python3), it
works perfectly. Thank you.

And the patch file is attached .

[-- Attachment #2: 0001-Enhance-python-tests.el-to-adapt-different-python-in.patch --]
[-- Type: text/x-patch, Size: 17745 bytes --]

From 918de75b5e5de1c052c6d8067b8232d04d9869ce Mon Sep 17 00:00:00 2001
From: Lin Sun <sunlin7@hotmail.com>
Date: Fri, 3 May 2024 06:52:22 +0000
Subject: [PATCH] Enhance python-tests.el to adapt different python
 interpreters (bug#70815)

* test/lisp/progmodes/python-tests.el
  (python-tests-get-shell-interpreter): New function to get python
  interpreter for testing; and also introduce new env variable
  EMACS_PYTHON_INTERPRETER to support customer python interpreter.

Co-authored-by: kobarity <kobarity@gmail.com>
---
 test/lisp/progmodes/python-tests.el | 102 ++++++++++++++++------------
 1 file changed, 60 insertions(+), 42 deletions(-)

diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
index f50797953c3..4364c11a76b 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -21,6 +21,7 @@
 
 ;;; Code:
 
+(require 'cl-extra)
 (require 'ert)
 (require 'ert-x)
 (require 'python)
@@ -58,7 +59,8 @@ turned off.  Shell buffer will be killed on exit."
   (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
@@ -3718,7 +3720,19 @@ if x:
 \f
 ;;; Shell integration
 
-(defvar python-tests-shell-interpreter "python")
+(defvar python-tests-shell-interpreter nil)
+
+(defun python-tests-get-shell-interpreter ()
+  "Get the shell interpreter.
+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
+          (or (when-let ((interpreter (getenv "EMACS_PYTHON_INTERPRETER")))
+                (or (executable-find interpreter)
+                    (error "Couldn't find EMACS_PYTHON_INTERPRETER(%s) in path"
+                           interpreter)))
+              (cl-some #'executable-find '("python" "python3" "python2"))))))
 
 (ert-deftest python-shell-get-process-name-1 ()
   "Check process name calculation sans `buffer-file-name'."
@@ -3980,13 +3994,13 @@ if x:
 
 (ert-deftest python-shell-make-comint-1 ()
   "Check comint creation for global shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   ;; The interpreter can get killed too quickly to allow it to clean
   ;; up the tempfiles that the default python-shell-setup-codes create,
   ;; so it leaves tempfiles behind, which is a minor irritation.
   (let* ((python-shell-setup-codes nil)
          (python-shell-interpreter
-          (executable-find python-tests-shell-interpreter))
+          (python-tests-get-shell-interpreter))
          (proc-name (python-shell-get-process-name nil))
          (shell-buffer
           (python-tests-with-temp-buffer
@@ -4004,10 +4018,10 @@ if x:
 
 (ert-deftest python-shell-make-comint-2 ()
   "Check comint creation for internal shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((python-shell-setup-codes nil)
          (python-shell-interpreter
-          (executable-find python-tests-shell-interpreter))
+          (python-tests-get-shell-interpreter))
          (proc-name (python-shell-internal-get-process-name))
          (shell-buffer
           (python-tests-with-temp-buffer
@@ -4028,13 +4042,13 @@ if x:
 The command passed to `python-shell-make-comint' as argument must
 locally override global values set in `python-shell-interpreter'
 and `python-shell-interpreter-args' in the new shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((python-shell-setup-codes nil)
          (python-shell-interpreter "interpreter")
          (python-shell-interpreter-args "--some-args")
          (proc-name (python-shell-get-process-name nil))
          (interpreter-override
-          (concat (executable-find python-tests-shell-interpreter) " " "-i"))
+          (concat (python-tests-get-shell-interpreter) " " "-i"))
          (shell-buffer
           (python-tests-with-temp-buffer
            "" (python-shell-make-comint interpreter-override proc-name nil)))
@@ -4047,17 +4061,17 @@ and `python-shell-interpreter-args' in the new shell buffer."
             (should (eq major-mode 'inferior-python-mode))
             (should (file-equal-p
                      python-shell-interpreter
-                     (executable-find python-tests-shell-interpreter)))
+                     (python-tests-get-shell-interpreter)))
             (should (string= python-shell-interpreter-args "-i"))))
       (kill-buffer shell-buffer))))
 
 (ert-deftest python-shell-make-comint-4 ()
   "Check shell calculated prompts regexps are set."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((process-environment process-environment)
          (python-shell-setup-codes nil)
          (python-shell-interpreter
-          (executable-find python-tests-shell-interpreter))
+          (python-tests-get-shell-interpreter))
          (python-shell-interpreter-args "-i")
          (python-shell--prompt-calculated-input-regexp nil)
          (python-shell--prompt-calculated-output-regexp nil)
@@ -4099,12 +4113,12 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-get-process-1 ()
   "Check dedicated shell process preference over global."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-file
       ""
     (let* ((python-shell-setup-codes nil)
            (python-shell-interpreter
-            (executable-find python-tests-shell-interpreter))
+            (python-tests-get-shell-interpreter))
            (global-proc-name (python-shell-get-process-name nil))
            (dedicated-proc-name (python-shell-get-process-name t))
            (global-shell-buffer
@@ -4132,12 +4146,12 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-internal-get-or-create-process-1 ()
   "Check internal shell process creation fallback."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-file
    ""
    (should (not (process-live-p (python-shell-internal-get-process-name))))
    (let* ((python-shell-interpreter
-           (executable-find python-tests-shell-interpreter))
+           (python-tests-get-shell-interpreter))
           (internal-process-name (python-shell-internal-get-process-name))
           (internal-process (python-shell-internal-get-or-create-process))
           (internal-shell-buffer (process-buffer internal-process)))
@@ -4155,8 +4169,9 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-prompt-detect-1 ()
   "Check prompt autodetection."
-  (skip-unless (executable-find python-tests-shell-interpreter))
-  (let ((process-environment process-environment))
+  (skip-unless (python-tests-get-shell-interpreter))
+  (let ((process-environment process-environment)
+        (python-shell-interpreter (python-tests-get-shell-interpreter)))
     ;; Ensure no startup file is enabled
     (setenv "PYTHONSTARTUP" "")
     (should python-shell-prompt-detect-enabled)
@@ -4164,8 +4179,9 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-prompt-detect-2 ()
   "Check prompt autodetection with startup file.  Bug#17370."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (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"
@@ -4181,7 +4197,7 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-prompt-detect-3 ()
   "Check prompts are not autodetected when feature is disabled."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let ((process-environment process-environment)
         (python-shell-prompt-detect-enabled nil))
     ;; Ensure no startup file is enabled
@@ -4190,7 +4206,7 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-prompt-detect-4 ()
   "Check warning is shown when detection fails."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((process-environment process-environment)
          ;; Trigger failure by removing prompts in the startup file
          (startup-code (concat "import sys\n"
@@ -4211,7 +4227,7 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-prompt-detect-5 ()
   "Check disabled warnings are not shown when detection fails."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((process-environment process-environment)
          (startup-code (concat "import sys\n"
                                "sys.ps1 = ''\n"
@@ -4232,7 +4248,7 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-prompt-detect-6 ()
   "Warnings are not shown when detection is disabled."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((process-environment process-environment)
          (startup-code (concat "import sys\n"
                                "sys.ps1 = ''\n"
@@ -4396,7 +4412,7 @@ and `python-shell-interpreter-args' in the new shell buffer."
 
 (ert-deftest python-shell-prompt-set-calculated-regexps-6 ()
   "Check detected prompts are included `regexp-quote'd."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (let* ((python-shell-prompt-input-regexps '(""))
          (python-shell-prompt-output-regexps '(""))
          (python-shell-prompt-regexp "")
@@ -4406,6 +4422,7 @@ and `python-shell-interpreter-args' in the new shell buffer."
          (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"
@@ -4779,7 +4796,7 @@ def foo():
     (should (python-shell-completion-native-interpreter-disabled-p))))
 
 (ert-deftest python-shell-completion-at-point-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    ""
    (python-shell-with-shell-buffer
@@ -4793,7 +4810,7 @@ def foo():
      (should-not (nth 2 (python-shell-completion-at-point))))))
 
 (ert-deftest python-shell-completion-at-point-native-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    ""
    (python-shell-completion-native-turn-on)
@@ -4872,14 +4889,14 @@ def foo():
   "Return Jedi readline setup file if PYTHONSTARTUP is not set."
   (or (getenv "PYTHONSTARTUP")
       (with-temp-buffer
-        (if (eql 0 (call-process python-tests-shell-interpreter
+        (if (eql 0 (call-process (python-tests-get-shell-interpreter)
                                  nil t nil "-m" "jedi" "repl"))
             (string-trim (buffer-string))
           ""))))
 
 (ert-deftest python-shell-completion-at-point-jedi-completer ()
   "Check if Python shell completion works when Jedi completer is used."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (with-environment-variables
       (("PYTHONSTARTUP" (python-tests--pythonstartup-file)))
     (python-tests-with-temp-buffer-with-shell
@@ -4924,7 +4941,7 @@ def foo():
 ;;; Symbol completion
 
 (ert-deftest python-completion-at-point-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -4942,7 +4959,7 @@ import abc
 
 (ert-deftest python-completion-at-point-2 ()
   "Should work regardless of the point in the Shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -4960,7 +4977,7 @@ import abc
 
 (ert-deftest python-completion-at-point-pdb-1 ()
   "Should not complete PDB commands in Python buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import pdb
@@ -4979,7 +4996,7 @@ print('Hello')
 
 (ert-deftest python-completion-at-point-while-running-1 ()
   "Should not try to complete when a program is running in the Shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import time
@@ -4995,7 +5012,7 @@ time.sleep(3)
      (should-not (with-timeout (1 t) (completion-at-point))))))
 
 (ert-deftest python-completion-at-point-native-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -5014,7 +5031,7 @@ import abc
 
 (ert-deftest python-completion-at-point-native-2 ()
   "Should work regardless of the point in the Shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -5032,7 +5049,7 @@ import abc
      (should (completion-at-point)))))
 
 (ert-deftest python-completion-at-point-native-with-ffap-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -5050,7 +5067,7 @@ import abc
      (should (completion-at-point)))))
 
 (ert-deftest python-completion-at-point-native-with-eldoc-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -5077,7 +5094,7 @@ import abc
 ;;; FFAP
 
 (ert-deftest python-ffap-module-path-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -5089,7 +5106,7 @@ import abc
 
 (ert-deftest python-ffap-module-path-while-running-1 ()
   "Should not get module path when a program is running in the Shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -5165,7 +5182,7 @@ some_symbol   some_other_symbol
                     "some_symbol"))))
 
 (ert-deftest python-eldoc--get-doc-at-point-1 ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import time
@@ -5178,7 +5195,7 @@ import time
 
 (ert-deftest python-eldoc--get-doc-at-point-while-running-1 ()
   "Should not get documentation when a program is running in the Shell buffer."
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
    "
 import time
@@ -7396,8 +7413,9 @@ buffer with overlapping strings."
 ;; interpreter.
 (ert-deftest python-tests--run-python-selects-window ()
   "Test for bug#31398.  See also bug#44421 and bug#52380."
-  (skip-unless (executable-find python-tests-shell-interpreter))
-  (let* ((buffer (process-buffer (run-python nil nil 'show)))
+  (skip-unless (python-tests-get-shell-interpreter))
+  (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
@@ -7467,7 +7485,7 @@ buffer with overlapping strings."
                        "W0611: Unused import a.b.c (unused-import)"))))))
 
 (ert-deftest python-test--shell-send-block ()
-  (skip-unless (executable-find python-tests-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter))
   (python-tests-with-temp-buffer-with-shell
     "print('current 0')
 for x in range(1,3):
-- 
2.20.5


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-21 15:34             ` Lin Sun
@ 2024-05-22 14:38               ` kobarity
  2024-05-23 13:09                 ` Eli Zaretskii
  0 siblings, 1 reply; 49+ messages in thread
From: kobarity @ 2024-05-22 14:38 UTC (permalink / raw)
  To: Lin Sun; +Cc: Eli Zaretskii, Stefan Kangas, 70815


Lin Sun wrote:
> On Tue, May 21, 2024 at 2:04 PM kobarity <kobarity@gmail.com> wrote:
> >
> >
> > Lin Sun wrote:
> > > On Mon, May 20, 2024 at 3:53 PM kobarity <kobarity@gmail.com> wrote:
> > > > 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.
> > >
> > > Thank you for the comments, now get your points and agree with you.
> > > I merged your patch together, also corrected the typo in the commit message.
> > > Please help review the attached patch. Thank you !
> >
> > Sorry, there was a problem in my diff.  Two tests fail when
> > EMACS_PYTHON_INTERPRETER is not found.  Please apply the attached
> > diff.  It also includes a suggestion for improving the error message.
> > Please consider.
> 
> Merged your changes and tested on my local (with python/python3), it
> works perfectly. Thank you.
> 
> And the patch file is attached .

Thanks, it looks good to me.





^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-22 14:38               ` kobarity
@ 2024-05-23 13:09                 ` Eli Zaretskii
  0 siblings, 0 replies; 49+ messages in thread
From: Eli Zaretskii @ 2024-05-23 13:09 UTC (permalink / raw)
  To: kobarity; +Cc: sunlin7.mail, stefankangas, 70815-done

> Date: Wed, 22 May 2024 23:38:02 +0900
> From: kobarity <kobarity@gmail.com>
> Cc: Eli Zaretskii <eliz@gnu.org>,
> 	Stefan Kangas <stefankangas@gmail.com>,
> 	70815@debbugs.gnu.org
> 
> 
> Lin Sun wrote:
> > On Tue, May 21, 2024 at 2:04 PM kobarity <kobarity@gmail.com> wrote:
> > >
> > >
> > > Lin Sun wrote:
> > > > On Mon, May 20, 2024 at 3:53 PM kobarity <kobarity@gmail.com> wrote:
> > > > > 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.
> > > >
> > > > Thank you for the comments, now get your points and agree with you.
> > > > I merged your patch together, also corrected the typo in the commit message.
> > > > Please help review the attached patch. Thank you !
> > >
> > > Sorry, there was a problem in my diff.  Two tests fail when
> > > EMACS_PYTHON_INTERPRETER is not found.  Please apply the attached
> > > diff.  It also includes a suggestion for improving the error message.
> > > Please consider.
> > 
> > Merged your changes and tested on my local (with python/python3), it
> > works perfectly. Thank you.
> > 
> > And the patch file is attached .
> 
> Thanks, it looks good to me.

Thanks, installed on master, and closing.





^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  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-18 22:20 ` Stefan Kangas
@ 2024-05-26 10:52 ` Mattias Engdegård
  2024-05-26 12:05   ` kobarity
  2024-05-26 15:36   ` Eli Zaretskii
  2 siblings, 2 replies; 49+ messages in thread
From: Mattias Engdegård @ 2024-05-26 10:52 UTC (permalink / raw)
  To: kobarity; +Cc: Eli Zaretskii, Lin Sun, stefankangas, 70815

[-- Attachment #1: Type: text/plain, Size: 525 bytes --]

This change caused python-tests failures on macOS. See attached log.

On this machine which has the standard macOS Python installation, 'python' is python 2, which apparently the tests don't cope very well with. (Have you verified that they do?)

The tests pass if modified to prefer Python 3:

@@ -3722,2 +3722,2 @@ python-tests-get-shell-interpreter
-              (cl-some #'executable-find '("python" "python3" "python2"))))))
+              (cl-some #'executable-find '("python3" "python" "python2"))))))




[-- Attachment #2: python-tests.log --]
[-- Type: application/octet-stream, Size: 36491 bytes --]

Running 359 tests (2024-05-26 12:39:46+0200, selector `(not (or (tag :unstable) (tag :nativecomp)))')
   passed    1/359  python-auto-fill-docstring (0.000899 sec)
Fontifying  *temp*-953703...
Fontifying  *temp*-953703... (syntactically...)
Fontifying  *temp*-953703... (regexps...)
Fontifying  *temp*-953703... (regexps....)
Fontifying  *temp*-953703... (regexps.....)
Fontifying  *temp*-953703... (regexps......)
Fontifying  *temp*-953703... (regexps.......)
Fontifying  *temp*-953703... (regexps........)
Fontifying  *temp*-953703... (regexps.........)
Fontifying  *temp*-953703... (regexps..........)
Fontifying  *temp*-953703... (regexps...........)
Fontifying  *temp*-953703... (regexps............)
Fontifying  *temp*-953703... (regexps.............)
Fontifying  *temp*-953703... (regexps..............)
Fontifying  *temp*-953703... (regexps...............)
Fontifying  *temp*-953703... (regexps................)
Fontifying  *temp*-953703... (regexps.................)

   passed    2/359  python-bob-infloop-avoid (0.000720 sec)
Test python-completion-at-point-1 backtrace:
  signal(ert-test-failed (((should (completion-at-point)) :form (compl
  ert-fail(((should (completion-at-point)) :form (completion-at-point)
  #f(compiled-function () #<bytecode 0x1e8b4c6a7c79bb47>)()
  #f(compiled-function () #<bytecode -0x15266b19ba44d40b>)()
  handler-bind-1(#f(compiled-function () #<bytecode -0x15266b19ba44d40
  ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
  ert-run-test(#s(ert-test :name python-completion-at-point-1 :documen
  ert-run-or-rerun-test(#s(ert--stats :selector ... :tests ... :test-m
  ert-run-tests((not (or (tag :unstable) (tag :nativecomp))) #f(compil
  ert-run-tests-batch((not (or (tag :unstable) (tag :nativecomp))))
  ert-run-tests-batch-and-exit((not (or (tag :unstable) (tag :nativeco
  eval((ert-run-tests-batch-and-exit '(not (or (tag :unstable) (tag :n
  command-line-1(("-L" ":../../emacs/test" "-l" "ert" "--eval" "(setq 
  command-line()
  normal-top-level()
Test python-completion-at-point-1 condition:
    (ert-test-failed
     ((should (completion-at-point)) :form (completion-at-point) :value
      nil))
   FAILED    3/359  python-completion-at-point-1 (0.297276 sec) at ../../emacs/test/lisp/progmodes/python-tests.el:4930
Test python-completion-at-point-2 backtrace:
  signal(ert-test-failed (((should (completion-at-point)) :form (compl
  ert-fail(((should (completion-at-point)) :form (completion-at-point)
  #f(compiled-function () #<bytecode -0xc07eb83eb000dec>)()
  #f(compiled-function () #<bytecode -0x15266b19ba44d40b>)()
  handler-bind-1(#f(compiled-function () #<bytecode -0x15266b19ba44d40
  ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
  ert-run-test(#s(ert-test :name python-completion-at-point-2 :documen
  ert-run-or-rerun-test(#s(ert--stats :selector ... :tests ... :test-m
  ert-run-tests((not (or (tag :unstable) (tag :nativecomp))) #f(compil
  ert-run-tests-batch((not (or (tag :unstable) (tag :nativecomp))))
  ert-run-tests-batch-and-exit((not (or (tag :unstable) (tag :nativeco
  eval((ert-run-tests-batch-and-exit '(not (or (tag :unstable) (tag :n
  command-line-1(("-L" ":../../emacs/test" "-l" "ert" "--eval" "(setq 
  command-line()
  normal-top-level()
Test python-completion-at-point-2 condition:
    (ert-test-failed
     ((should (completion-at-point)) :form (completion-at-point) :value
      nil))
   FAILED    4/359  python-completion-at-point-2 (0.276322 sec) at ../../emacs/test/lisp/progmodes/python-tests.el:4947
Test python-completion-at-point-native-1 backtrace:
  signal(ert-test-failed (((should (completion-at-point)) :form (compl
  ert-fail(((should (completion-at-point)) :form (completion-at-point)
  #f(compiled-function () #<bytecode 0x34326b9d63488b8>)()
  #f(compiled-function () #<bytecode -0x15266b19ba44d40b>)()
  handler-bind-1(#f(compiled-function () #<bytecode -0x15266b19ba44d40
  ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
  ert-run-test(#s(ert-test :name python-completion-at-point-native-1 :
  ert-run-or-rerun-test(#s(ert--stats :selector ... :tests ... :test-m
  ert-run-tests((not (or (tag :unstable) (tag :nativecomp))) #f(compil
  ert-run-tests-batch((not (or (tag :unstable) (tag :nativecomp))))
  ert-run-tests-batch-and-exit((not (or (tag :unstable) (tag :nativeco
  eval((ert-run-tests-batch-and-exit '(not (or (tag :unstable) (tag :n
  command-line-1(("-L" ":../../emacs/test" "-l" "ert" "--eval" "(setq 
  command-line()
  normal-top-level()
Test python-completion-at-point-native-1 condition:
    (ert-test-failed
     ((should (completion-at-point)) :form (completion-at-point) :value
      nil))
   FAILED    5/359  python-completion-at-point-native-1 (2.287985 sec) at ../../emacs/test/lisp/progmodes/python-tests.el:5001
Test python-completion-at-point-native-2 backtrace:
  signal(ert-test-failed (((should (completion-at-point)) :form (compl
  ert-fail(((should (completion-at-point)) :form (completion-at-point)
  #f(compiled-function () #<bytecode 0x17cc5ab75b63540f>)()
  #f(compiled-function () #<bytecode -0x15266b19ba44d40b>)()
  handler-bind-1(#f(compiled-function () #<bytecode -0x15266b19ba44d40
  ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
  ert-run-test(#s(ert-test :name python-completion-at-point-native-2 :
  ert-run-or-rerun-test(#s(ert--stats :selector ... :tests ... :test-m
  ert-run-tests((not (or (tag :unstable) (tag :nativecomp))) #f(compil
  ert-run-tests-batch((not (or (tag :unstable) (tag :nativecomp))))
  ert-run-tests-batch-and-exit((not (or (tag :unstable) (tag :nativeco
  eval((ert-run-tests-batch-and-exit '(not (or (tag :unstable) (tag :n
  command-line-1(("-L" ":../../emacs/test" "-l" "ert" "--eval" "(setq 
  command-line()
  normal-top-level()
Test python-completion-at-point-native-2 condition:
    (ert-test-failed
     ((should (completion-at-point)) :form (completion-at-point) :value
      nil))
   FAILED    6/359  python-completion-at-point-native-2 (2.301811 sec) at ../../emacs/test/lisp/progmodes/python-tests.el:5019
Test python-completion-at-point-native-with-eldoc-1 backtrace:
  signal(ert-test-failed (((should (completion-at-point)) :form (compl
  ert-fail(((should (completion-at-point)) :form (completion-at-point)
  #f(compiled-function () #<bytecode -0xe97b868aec9aafc>)()
  #f(compiled-function () #<bytecode -0x15266b19ba44d40b>)()
  handler-bind-1(#f(compiled-function () #<bytecode -0x15266b19ba44d40
  ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
  ert-run-test(#s(ert-test :name python-completion-at-point-native-wit
  ert-run-or-rerun-test(#s(ert--stats :selector ... :tests ... :test-m
  ert-run-tests((not (or (tag :unstable) (tag :nativecomp))) #f(compil
  ert-run-tests-batch((not (or (tag :unstable) (tag :nativecomp))))
  ert-run-tests-batch-and-exit((not (or (tag :unstable) (tag :nativeco
  eval((ert-run-tests-batch-and-exit '(not (or (tag :unstable) (tag :n
  command-line-1(("-L" ":../../emacs/test" "-l" "ert" "--eval" "(setq 
  command-line()
  normal-top-level()
Test python-completion-at-point-native-with-eldoc-1 condition:
    (ert-test-failed
     ((should (completion-at-point)) :form (completion-at-point) :value
      nil))
   FAILED    7/359  python-completion-at-point-native-with-eldoc-1 (2.334841 sec) at ../../emacs/test/lisp/progmodes/python-tests.el:5056
Test python-completion-at-point-native-with-ffap-1 backtrace:
  signal(ert-test-failed (((should (completion-at-point)) :form (compl
  ert-fail(((should (completion-at-point)) :form (completion-at-point)
  #f(compiled-function () #<bytecode -0xee9f54223d6720a>)()
  #f(compiled-function () #<bytecode -0x15266b19ba44d40b>)()
  handler-bind-1(#f(compiled-function () #<bytecode -0x15266b19ba44d40
  ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
  ert-run-test(#s(ert-test :name python-completion-at-point-native-wit
  ert-run-or-rerun-test(#s(ert--stats :selector ... :tests ... :test-m
  ert-run-tests((not (or (tag :unstable) (tag :nativecomp))) #f(compil
  ert-run-tests-batch((not (or (tag :unstable) (tag :nativecomp))))
  ert-run-tests-batch-and-exit((not (or (tag :unstable) (tag :nativeco
  eval((ert-run-tests-batch-and-exit '(not (or (tag :unstable) (tag :n
  command-line-1(("-L" ":../../emacs/test" "-l" "ert" "--eval" "(setq 
  command-line()
  normal-top-level()
Test python-completion-at-point-native-with-ffap-1 condition:
    (ert-test-failed
     ((should (completion-at-point)) :form (completion-at-point) :value
      nil))
   FAILED    8/359  python-completion-at-point-native-with-ffap-1 (2.323007 sec) at ../../emacs/test/lisp/progmodes/python-tests.el:5038
   passed    9/359  python-completion-at-point-pdb-1 (0.273743 sec)
   passed   10/359  python-completion-at-point-while-running-1 (0.159660 sec)
   passed   11/359  python-eldoc--get-doc-at-point-1 (0.301881 sec)
   passed   12/359  python-eldoc--get-doc-at-point-while-running-1 (0.154338 sec)
   passed   13/359  python-eldoc--get-symbol-at-point-1 (0.001642 sec)
   passed   14/359  python-eldoc--get-symbol-at-point-2 (0.001778 sec)
   passed   15/359  python-eldoc--get-symbol-at-point-3 (0.000370 sec)
   passed   16/359  python-eldoc--get-symbol-at-point-4 (0.000480 sec)
   passed   17/359  python-end-of-defun-1 (0.000622 sec)
   passed   18/359  python-ffap-module-path-1 (0.298471 sec)
   passed   19/359  python-ffap-module-path-while-running-1 (0.160546 sec)
   passed   20/359  python-fill-docstring (0.001283 sec)
   passed   21/359  python-fill-paragraph-single-quoted-string-1 (0.000362 sec)
   passed   22/359  python-fill-paragraph-single-quoted-string-2 (0.000296 sec)
   passed   23/359  python-fill-paragraph-triple-quoted-string-1 (0.004185 sec)
   passed   24/359  python-font-lock-assignment-statement-1 (0.000521 sec)
   passed   25/359  python-font-lock-assignment-statement-10 (0.000360 sec)
   passed   26/359  python-font-lock-assignment-statement-11 (0.000580 sec)
   passed   27/359  python-font-lock-assignment-statement-12 (0.000373 sec)
   passed   28/359  python-font-lock-assignment-statement-13 (0.000499 sec)
   passed   29/359  python-font-lock-assignment-statement-14 (0.000340 sec)
   passed   30/359  python-font-lock-assignment-statement-15 (0.000333 sec)
   passed   31/359  python-font-lock-assignment-statement-16 (0.000339 sec)
   passed   32/359  python-font-lock-assignment-statement-17 (0.000297 sec)
   passed   33/359  python-font-lock-assignment-statement-18 (0.000789 sec)
   passed   34/359  python-font-lock-assignment-statement-2 (0.000752 sec)
   passed   35/359  python-font-lock-assignment-statement-3 (0.000563 sec)
   passed   36/359  python-font-lock-assignment-statement-4 (0.000558 sec)
   passed   37/359  python-font-lock-assignment-statement-5 (0.000575 sec)
   passed   38/359  python-font-lock-assignment-statement-6 (0.000394 sec)
   passed   39/359  python-font-lock-assignment-statement-7 (0.000447 sec)
   passed   40/359  python-font-lock-assignment-statement-8 (0.000519 sec)
   passed   41/359  python-font-lock-assignment-statement-9 (0.000836 sec)
   passed   42/359  python-font-lock-escape-sequence-bytes-newline (0.000580 sec)
   passed   43/359  python-font-lock-escape-sequence-hex-octal (0.001087 sec)
   passed   44/359  python-font-lock-escape-sequence-multiline-string (0.013170 sec)
   passed   45/359  python-font-lock-escape-sequence-string-newline (0.001243 sec)
   passed   46/359  python-font-lock-escape-sequence-unicode (0.000684 sec)
   passed   47/359  python-font-lock-keywords-level-1-1 (0.000727 sec)
   passed   48/359  python-font-lock-keywords-level-1-2 (0.000425 sec)
   passed   49/359  python-font-lock-raw-escape-sequence (0.000793 sec)
   passed   50/359  python-font-lock-string-literal-concatenation (0.000646 sec)
Hiding all blocks... 
Hiding all blocks...done
   passed   51/359  python-hideshow-hide-all-1 (0.000806 sec)
Hiding all blocks... 
Hiding all blocks...done
   passed   52/359  python-hideshow-hide-all-2 (0.000765 sec)
Hiding all blocks... 
Hiding all blocks...done
   passed   53/359  python-hideshow-hide-all-3 (0.000419 sec)
   passed   54/359  python-hideshow-hide-block-1 (0.000904 sec)
Hiding blocks ...
Hiding blocks ... done
Showing all blocks ...
Showing all blocks ... done
   passed   55/359  python-hideshow-hide-levels-1 (0.001155 sec)
Showing all blocks ...
Showing all blocks ... done
   passed   56/359  python-hideshow-hide-levels-2 (0.000408 sec)
Hiding blocks ...
Hiding blocks ... done
   passed   57/359  python-hideshow-hide-levels-3 (0.000542 sec)
Hiding blocks ...
Hiding blocks ... done
   passed   58/359  python-hideshow-hide-levels-4 (0.001606 sec)
   passed   59/359  python-imenu-create-flat-index-1 (0.001509 sec)
   passed   60/359  python-imenu-create-flat-index-2 (0.000704 sec)
   passed   61/359  python-imenu-create-index-1 (0.000551 sec)
   passed   62/359  python-imenu-create-index-2 (0.000324 sec)
   passed   63/359  python-imenu-create-index-3 (0.000401 sec)
   passed   64/359  python-imenu-create-index-4 (0.000567 sec)
   passed   65/359  python-indent-after-async-block-1 (0.000412 sec)
   passed   66/359  python-indent-after-async-block-2 (0.000337 sec)
   passed   67/359  python-indent-after-async-block-3 (0.000609 sec)
   passed   68/359  python-indent-after-backslash-1 (0.000702 sec)
   passed   69/359  python-indent-after-backslash-2 (0.001052 sec)
   passed   70/359  python-indent-after-backslash-3 (0.000494 sec)
   passed   71/359  python-indent-after-backslash-4 (0.000520 sec)
   passed   72/359  python-indent-after-backslash-5 (0.000502 sec)
   passed   73/359  python-indent-after-backslash-6 (0.000697 sec)
   passed   74/359  python-indent-after-bare-match (0.000356 sec)
   passed   75/359  python-indent-after-block-1 (0.000308 sec)
   passed   76/359  python-indent-after-block-2 (0.000301 sec)
   passed   77/359  python-indent-after-block-3 (0.000656 sec)
   passed   78/359  python-indent-after-case-block (0.000285 sec)
   passed   79/359  python-indent-after-comment-1 (0.001490 sec)
   passed   80/359  python-indent-after-comment-2 (0.002461 sec)
   passed   81/359  python-indent-after-comment-3 (0.000940 sec)
   passed   82/359  python-indent-after-match-block (0.000480 sec)
   passed   83/359  python-indent-after-re-match (0.000323 sec)
   passed   84/359  python-indent-base-case (0.000282 sec)
   passed   85/359  python-indent-block-enders-1 (0.000357 sec)
   passed   86/359  python-indent-block-enders-2 (0.000622 sec)
   passed   87/359  python-indent-block-enders-3 (0.000557 sec)
   passed   88/359  python-indent-block-enders-4 (0.000834 sec)
   passed   89/359  python-indent-block-enders-5 (0.000698 sec)
   passed   90/359  python-indent-dedent-line-backspace-1 (0.000657 sec)
   passed   91/359  python-indent-dedent-line-backspace-2 (0.000314 sec)
   passed   92/359  python-indent-dedent-line-backspace-3 (0.000475 sec)
   passed   93/359  python-indent-dedenters-1 (0.000463 sec)
Closes if hide_details:
Closes except Exception:
Closes if save:
   passed   94/359  python-indent-dedenters-2 (0.002554 sec)
Closes try:
   passed   95/359  python-indent-dedenters-3 (0.000756 sec)
Closes try:
   passed   96/359  python-indent-dedenters-4 (0.000586 sec)
Closes if save:
   passed   97/359  python-indent-dedenters-5 (0.001060 sec)
   passed   98/359  python-indent-dedenters-6 (0.000385 sec)
   passed   99/359  python-indent-dedenters-7 (0.000401 sec)
Closes if (a == 1 or
Closes if (a == 1 or
Closes if (a == 1 or
   passed  100/359  python-indent-dedenters-8 (0.000899 sec)
Closes case 1:
   passed  101/359  python-indent-dedenters-9 (0.000563 sec)
Closes if hide_details:
Closes except Exception:
Closes if save:
   passed  102/359  python-indent-dedenters-comment-else (0.003009 sec)
   passed  103/359  python-indent-electric-colon-1 (0.000340 sec)
Closes if do:
   passed  104/359  python-indent-electric-colon-2 (0.000421 sec)
Closes if do:
Closes if do:
Closes if do:
   passed  105/359  python-indent-electric-colon-3 (0.000766 sec)
Closes if True:
   passed  106/359  python-indent-electric-colon-4 (0.000799 sec)
   passed  107/359  python-indent-electric-comma-after-multiline-string (0.000422 sec)
   passed  108/359  python-indent-electric-comma-inside-multiline-string (0.000966 sec)
   passed  109/359  python-indent-hanging-close-paren (0.000345 sec)
   passed  110/359  python-indent-inside-paren-1 (0.000925 sec)
   passed  111/359  python-indent-inside-paren-2 (0.000701 sec)
   passed  112/359  python-indent-inside-paren-3 (0.000387 sec)
   passed  113/359  python-indent-inside-paren-4 (0.000339 sec)
   passed  114/359  python-indent-inside-paren-5 (0.000899 sec)
   passed  115/359  python-indent-inside-paren-6 (0.000630 sec)
   passed  116/359  python-indent-inside-paren-7 (0.000438 sec)
   passed  117/359  python-indent-inside-paren-8 (0.000524 sec)
   passed  118/359  python-indent-inside-paren-9 (0.000824 sec)
   passed  119/359  python-indent-inside-paren-block-1 (0.000830 sec)
   passed  120/359  python-indent-inside-paren-block-2 (0.001032 sec)
   passed  121/359  python-indent-inside-paren-block-3 (0.000948 sec)
   passed  122/359  python-indent-inside-paren-block-4 (0.000591 sec)
   passed  123/359  python-indent-inside-string-1 (0.000554 sec)
   passed  124/359  python-indent-inside-string-2 (0.001573 sec)
   passed  125/359  python-indent-inside-string-3 (0.000727 sec)
   passed  126/359  python-indent-pep8-1 (0.000396 sec)
   passed  127/359  python-indent-pep8-2 (0.000481 sec)
   passed  128/359  python-indent-pep8-3 (0.000387 sec)
   passed  129/359  python-indent-region-1 (0.000297 sec)
   passed  130/359  python-indent-region-2 (0.000546 sec)
   passed  131/359  python-indent-region-3 (0.000473 sec)
   passed  132/359  python-indent-region-4 (0.000410 sec)
   passed  133/359  python-indent-region-5 (0.002028 sec)
   passed  134/359  python-info-assignment-continuation-line-p-1 (0.000807 sec)
   passed  135/359  python-info-assignment-continuation-line-p-2 (0.000627 sec)
   passed  136/359  python-info-assignment-statement-p-1 (0.001395 sec)
   passed  137/359  python-info-assignment-statement-p-2 (0.000490 sec)
   passed  138/359  python-info-assignment-statement-p-3 (0.000431 sec)
   passed  139/359  python-info-beginning-of-backslash-1 (0.000608 sec)
   passed  140/359  python-info-beginning-of-block-p-1 (0.000352 sec)
   passed  141/359  python-info-beginning-of-block-p-2 (0.000287 sec)
   passed  142/359  python-info-beginning-of-statement-p-1 (0.000264 sec)
   passed  143/359  python-info-beginning-of-statement-p-2 (0.000270 sec)
   passed  144/359  python-info-block-continuation-line-p-1 (0.000291 sec)
   passed  145/359  python-info-block-continuation-line-p-2 (0.000455 sec)
   passed  146/359  python-info-continuation-line-p-1 (0.000420 sec)
   passed  147/359  python-info-current-defun-1 (0.000656 sec)
   passed  148/359  python-info-current-defun-2 (0.012907 sec)
   passed  149/359  python-info-current-defun-3 (0.008910 sec)
   passed  150/359  python-info-current-defun-4 (0.001674 sec)
   passed  151/359  python-info-current-line-comment-p-1 (0.000492 sec)
   passed  152/359  python-info-current-line-empty-p (0.000376 sec)
   passed  153/359  python-info-current-symbol-1 (0.000494 sec)
   passed  154/359  python-info-current-symbol-2 (0.000633 sec)
   failed  155/359  python-info-current-symbol-3 (0.000355 sec)
   passed  156/359  python-info-dedenter-opening-block-message-1 (0.000290 sec)
Closes try:
Closes try:
   passed  157/359  python-info-dedenter-opening-block-message-2 (0.000346 sec)
Closes except:
Closes except:
   passed  158/359  python-info-dedenter-opening-block-message-3 (0.000612 sec)
Closes else:
Closes else:
   passed  159/359  python-info-dedenter-opening-block-message-4 (0.000484 sec)
Closes if a:
Closes if a:
   passed  160/359  python-info-dedenter-opening-block-message-5 (0.034931 sec)
   passed  161/359  python-info-dedenter-opening-block-position-1 (0.000686 sec)
   passed  162/359  python-info-dedenter-opening-block-position-2 (0.000395 sec)
   passed  163/359  python-info-dedenter-opening-block-position-3 (0.002207 sec)
   passed  164/359  python-info-dedenter-opening-block-positions-1 (0.001998 sec)
   passed  165/359  python-info-dedenter-opening-block-positions-2 (0.000844 sec)
   passed  166/359  python-info-dedenter-opening-block-positions-3 (0.000928 sec)
   passed  167/359  python-info-dedenter-opening-block-positions-4 (0.000321 sec)
   passed  168/359  python-info-dedenter-opening-block-positions-5 (0.000371 sec)
   passed  169/359  python-info-dedenter-opening-block-positions-6 (0.000277 sec)
   passed  170/359  python-info-dedenter-opening-block-positions-7 (0.000338 sec)
   passed  171/359  python-info-dedenter-statement-p-1 (0.000242 sec)
   passed  172/359  python-info-dedenter-statement-p-2 (0.000246 sec)
   passed  173/359  python-info-dedenter-statement-p-3 (0.000431 sec)
   passed  174/359  python-info-dedenter-statement-p-4 (0.000277 sec)
   passed  175/359  python-info-dedenter-statement-p-5 (0.000269 sec)
   passed  176/359  python-info-dedenter-statement-p-6 (0.000325 sec)
   passed  177/359  python-info-docstring-p-1 (0.001006 sec)
   passed  178/359  python-info-docstring-p-2 (0.001240 sec)
   passed  179/359  python-info-docstring-p-3 (0.002841 sec)
   passed  180/359  python-info-docstring-p-4 (0.001898 sec)
   passed  181/359  python-info-docstring-p-5 (0.001799 sec)
   passed  182/359  python-info-docstring-p-6 (0.001230 sec)
   passed  183/359  python-info-docstring-p-7 (0.000332 sec)
   passed  184/359  python-info-docstring-p-8 (0.000330 sec)
   passed  185/359  python-info-encoding-1 (0.000240 sec)
   passed  186/359  python-info-encoding-2 (0.000201 sec)
   passed  187/359  python-info-encoding-from-cookie-1 (0.000200 sec)
   passed  188/359  python-info-encoding-from-cookie-2 (0.000199 sec)
   passed  189/359  python-info-encoding-from-cookie-3 (0.000342 sec)
   passed  190/359  python-info-encoding-from-cookie-4 (0.000243 sec)
   passed  191/359  python-info-encoding-from-cookie-5 (0.000211 sec)
   passed  192/359  python-info-encoding-from-cookie-6 (0.000204 sec)
   passed  193/359  python-info-encoding-from-cookie-7 (0.000225 sec)
   passed  194/359  python-info-end-of-block-p-1 (0.000484 sec)
   passed  195/359  python-info-end-of-block-p-2 (0.000612 sec)
   passed  196/359  python-info-end-of-statement-p-1 (0.000690 sec)
   passed  197/359  python-info-end-of-statement-p-2 (0.000862 sec)
   passed  198/359  python-info-line-ends-backslash-p-1 (0.000488 sec)
   passed  199/359  python-info-looking-at-beginning-of-block-1 (0.000827 sec)
   passed  200/359  python-info-looking-at-beginning-of-defun-1 (0.000884 sec)
   passed  201/359  python-info-looking-at-beginning-of-defun-2 (0.000494 sec)
   passed  202/359  python-info-looking-at-beginning-of-defun-3 (0.000291 sec)
   passed  203/359  python-info-statement-ends-block-p-1 (0.000808 sec)
   passed  204/359  python-info-statement-ends-block-p-2 (0.000524 sec)
   passed  205/359  python-info-statement-starts-block-p-1 (0.000860 sec)
   passed  206/359  python-info-statement-starts-block-p-2 (0.000394 sec)
   passed  207/359  python-info-triple-quoted-string-p-1 (0.000480 sec)
   passed  208/359  python-info-triple-quoted-string-p-2 (0.000423 sec)
   passed  209/359  python-info-triple-quoted-string-p-3 (0.000494 sec)
Mark set
Mark set
   passed  210/359  python-mark-defun-1 (0.001315 sec)
Mark set
Mark set
   passed  211/359  python-mark-defun-2 (0.000970 sec)
Mark set
Mark set
   passed  212/359  python-mark-defun-3 (0.000468 sec)
Mark set
Mark set
   passed  213/359  python-mark-defun-4 (0.000501 sec)
Mark set
Mark set
Mark set
Mark set
   passed  214/359  python-mark-defun-5 (0.000926 sec)
   passed  215/359  python-nav-backward-defun-1 (0.000474 sec)
   passed  216/359  python-nav-backward-defun-2 (0.000427 sec)
   passed  217/359  python-nav-backward-defun-3 (0.000443 sec)
   passed  218/359  python-nav-backward-defun-4 (0.000466 sec)
   passed  219/359  python-nav-backward-statement-1 (0.000662 sec)
   failed  220/359  python-nav-backward-statement-2 (0.001177 sec)
   failed  221/359  python-nav-backward-up-list-1 (0.000552 sec)
   passed  222/359  python-nav-beginning-of-block-1 (0.001246 sec)
   passed  223/359  python-nav-beginning-of-block-2 (0.000718 sec)
   passed  224/359  python-nav-beginning-of-defun-1 (0.001096 sec)
   passed  225/359  python-nav-beginning-of-defun-2 (0.000689 sec)
   passed  226/359  python-nav-beginning-of-defun-3 (0.000286 sec)
   passed  227/359  python-nav-beginning-of-defun-4 (0.000408 sec)
   passed  228/359  python-nav-beginning-of-defun-5 (0.000335 sec)
   passed  229/359  python-nav-beginning-of-defun-6 (0.000271 sec)
   passed  230/359  python-nav-beginning-of-statement-1 (0.000348 sec)
   passed  231/359  python-nav-end-of-block-1 (0.001285 sec)
   passed  232/359  python-nav-end-of-block-2 (0.000262 sec)
   passed  233/359  python-nav-end-of-defun-1 (0.001893 sec)
   passed  234/359  python-nav-end-of-defun-2 (0.002456 sec)
   passed  235/359  python-nav-end-of-defun-3 (0.000553 sec)
   passed  236/359  python-nav-end-of-statement-1 (0.000494 sec)
   passed  237/359  python-nav-end-of-statement-2 (0.000269 sec)
   passed  238/359  python-nav-end-of-statement-3 (0.000259 sec)
   passed  239/359  python-nav-end-of-statement-4 (0.000260 sec)
   passed  240/359  python-nav-forward-block-1 (0.000654 sec)
   passed  241/359  python-nav-forward-block-2 (0.000272 sec)
   passed  242/359  python-nav-forward-defun-1 (0.000311 sec)
   passed  243/359  python-nav-forward-defun-2 (0.000300 sec)
   passed  244/359  python-nav-forward-defun-3 (0.000259 sec)
   passed  245/359  python-nav-forward-defun-4 (0.000231 sec)
   passed  246/359  python-nav-forward-sexp-1 (0.000892 sec)
   passed  247/359  python-nav-forward-sexp-2 (0.001402 sec)
   passed  248/359  python-nav-forward-sexp-3 (0.001064 sec)
   passed  249/359  python-nav-forward-sexp-safe-1 (0.001452 sec)
   passed  250/359  python-nav-forward-statement-1 (0.000773 sec)
   passed  251/359  python-nav-up-list-1 (0.000296 sec)
   passed  252/359  python-parens-electric-indent-1 (0.001215 sec)
   passed  253/359  python-shell-buffer-substring-1 (0.000722 sec)
   passed  254/359  python-shell-buffer-substring-10 (0.000488 sec)
   passed  255/359  python-shell-buffer-substring-11 (0.000454 sec)
   passed  256/359  python-shell-buffer-substring-12 (0.000425 sec)
   passed  257/359  python-shell-buffer-substring-13 (0.000391 sec)
   passed  258/359  python-shell-buffer-substring-14 (0.000408 sec)
   passed  259/359  python-shell-buffer-substring-15 (0.000401 sec)
   passed  260/359  python-shell-buffer-substring-16 (0.000395 sec)
   passed  261/359  python-shell-buffer-substring-17 (0.000396 sec)
   passed  262/359  python-shell-buffer-substring-18 (0.000377 sec)
   passed  263/359  python-shell-buffer-substring-2 (0.000515 sec)
   passed  264/359  python-shell-buffer-substring-3 (0.000502 sec)
   passed  265/359  python-shell-buffer-substring-4 (0.000676 sec)
   passed  266/359  python-shell-buffer-substring-5 (0.000531 sec)
   passed  267/359  python-shell-buffer-substring-6 (0.000452 sec)
   passed  268/359  python-shell-buffer-substring-7 (0.000447 sec)
   passed  269/359  python-shell-buffer-substring-8 (0.000498 sec)
   passed  270/359  python-shell-buffer-substring-9 (0.000771 sec)
   passed  271/359  python-shell-calculate-exec-path-1 (0.000130 sec)
   passed  272/359  python-shell-calculate-exec-path-2 (0.000085 sec)
   passed  273/359  python-shell-calculate-exec-path-3 (0.000080 sec)
   passed  274/359  python-shell-calculate-exec-path-4 (0.001710 sec)
   passed  275/359  python-shell-calculate-exec-path-5 (0.000073 sec)
   passed  276/359  python-shell-calculate-exec-path-6 (0.000124 sec)
   passed  277/359  python-shell-calculate-process-environment-1 (0.000054 sec)
   passed  278/359  python-shell-calculate-process-environment-2 (0.000072 sec)
   passed  279/359  python-shell-calculate-process-environment-3 (0.000185 sec)
   passed  280/359  python-shell-calculate-process-environment-4 (0.000072 sec)
   passed  281/359  python-shell-calculate-process-environment-5 (0.000067 sec)
   passed  282/359  python-shell-calculate-process-environment-6 (0.000064 sec)
   passed  283/359  python-shell-calculate-process-environment-7 (0.000076 sec)
   passed  284/359  python-shell-calculate-process-environment-8 (0.000067 sec)
   passed  285/359  python-shell-calculate-pythonpath-1 (0.000064 sec)
   passed  286/359  python-shell-calculate-pythonpath-2 (0.000066 sec)
Test python-shell-completion-at-point-1 backtrace:
  signal(ert-test-failed (((should (nth 2 (python-shell-completion-at-
  ert-fail(((should (nth 2 (python-shell-completion-at-point))) :form 
  #f(compiled-function () #<bytecode -0x1c337af7c9e93016>)()
  #f(compiled-function () #<bytecode -0x15266b19ba44d40b>)()
  handler-bind-1(#f(compiled-function () #<bytecode -0x15266b19ba44d40
  ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
  ert-run-test(#s(ert-test :name python-shell-completion-at-point-1 :d
  ert-run-or-rerun-test(#s(ert--stats :selector ... :tests ... :test-m
  ert-run-tests((not (or (tag :unstable) (tag :nativecomp))) #f(compil
  ert-run-tests-batch((not (or (tag :unstable) (tag :nativecomp))))
  ert-run-tests-batch-and-exit((not (or (tag :unstable) (tag :nativeco
  eval((ert-run-tests-batch-and-exit '(not (or (tag :unstable) (tag :n
  command-line-1(("-L" ":../../emacs/test" "-l" "ert" "--eval" "(setq 
  command-line()
  normal-top-level()
Test python-shell-completion-at-point-1 condition:
    (ert-test-failed
     ((should (nth 2 (python-shell-completion-at-point))) :form
      (nth 2 nil) :value nil))
   FAILED  287/359  python-shell-completion-at-point-1 (0.293285 sec) at ../../emacs/test/lisp/progmodes/python-tests.el:4785
  skipped  288/359  python-shell-completion-at-point-ipython (0.000699 sec)
  skipped  289/359  python-shell-completion-at-point-jedi-completer (0.222261 sec)
   passed  290/359  python-shell-completion-at-point-native-1 (0.299456 sec)
   passed  291/359  python-shell-completion-native-interpreter-disabled-p-1 (0.000124 sec)
Can't guess python-indent-offset, using defaults: 4
   passed  292/359  python-shell-get-process-1 (0.113812 sec)
   passed  293/359  python-shell-get-process-name-1 (0.000381 sec)
Can't guess python-indent-offset, using defaults: 4
   passed  294/359  python-shell-get-process-name-2 (0.008759 sec)
Can't guess python-indent-offset, using defaults: 4
   passed  295/359  python-shell-internal-get-or-create-process-1 (0.058572 sec)
   passed  296/359  python-shell-internal-get-process-name-1 (0.000343 sec)
Can't guess python-indent-offset, using defaults: 4
   passed  297/359  python-shell-internal-get-process-name-2 (0.006695 sec)
   passed  298/359  python-shell-make-comint-1 (0.050022 sec)
   passed  299/359  python-shell-make-comint-2 (0.048224 sec)
   passed  300/359  python-shell-make-comint-3 (0.051549 sec)
   passed  301/359  python-shell-make-comint-4 (0.052049 sec)
   passed  302/359  python-shell-prompt-detect-1 (0.040509 sec)
   passed  303/359  python-shell-prompt-detect-2 (0.036072 sec)
   passed  304/359  python-shell-prompt-detect-3 (0.000137 sec)
Warning (python): Python shell prompts cannot be detected.
If your emacs session hangs when starting python shells
recover with `keyboard-quit' and then try fixing the
interactive flag for your interpreter by adjusting the
`python-shell-interpreter-interactive-arg' or add regexps
matching shell prompts in the directory-local friendly vars:
  + `python-shell-prompt-regexp'
  + `python-shell-prompt-block-regexp'
  + `python-shell-prompt-output-regexp'
Or alternatively in:
  + `python-shell-prompt-input-regexps'
  + `python-shell-prompt-output-regexps'
   passed  305/359  python-shell-prompt-detect-4 (0.091465 sec)
   passed  306/359  python-shell-prompt-detect-5 (0.076047 sec)
   passed  307/359  python-shell-prompt-detect-6 (0.000866 sec)
   passed  308/359  python-shell-prompt-set-calculated-regexps-1 (0.000099 sec)
   passed  309/359  python-shell-prompt-set-calculated-regexps-2 (0.000076 sec)
   passed  310/359  python-shell-prompt-set-calculated-regexps-3 (0.000069 sec)
   passed  311/359  python-shell-prompt-set-calculated-regexps-4 (0.000073 sec)
   passed  312/359  python-shell-prompt-set-calculated-regexps-5 (0.000078 sec)
   passed  313/359  python-shell-prompt-set-calculated-regexps-6 (0.042912 sec)
   passed  314/359  python-shell-prompt-validate-regexps-1 (0.000087 sec)
   passed  315/359  python-shell-prompt-validate-regexps-2 (0.000080 sec)
   passed  316/359  python-shell-prompt-validate-regexps-3 (0.000076 sec)
   passed  317/359  python-shell-prompt-validate-regexps-4 (0.000075 sec)
   passed  318/359  python-shell-prompt-validate-regexps-5 (0.000067 sec)
   passed  319/359  python-shell-prompt-validate-regexps-6 (0.000069 sec)
   passed  320/359  python-shell-prompt-validate-regexps-7 (0.000057 sec)
   passed  321/359  python-shell-with-environment-1 (0.000106 sec)
   passed  322/359  python-shell-with-environment-2 (0.000303 sec)
   passed  323/359  python-shell-with-environment-3 (0.000507 sec)
   passed  324/359  python-syntax-after-python-backspace (0.000332 sec)
   passed  325/359  python-syntax-context-1 (0.000307 sec)
Sent: for x in range(1,3):...
Sent:     print('current %s' % x)...
   passed  326/359  python-test--shell-send-block (0.363776 sec)
   passed  327/359  python-tests--fill-long-first-line (0.002034 sec)
   passed  328/359  python-tests--flymake-command-output-pattern (0.000157 sec)
   passed  329/359  python-tests--run-python-selects-window (0.052643 sec)
   passed  330/359  python-tests-look-at-1 (0.000348 sec)
   passed  331/359  python-tests-look-at-2 (0.000258 sec)
   passed  332/359  python-triple-double-quote-pairing (0.002244 sec)
   passed  333/359  python-triple-single-quote-pairing (0.001065 sec)
   passed  334/359  python-ts-mode-assignement-face-2 (0.078170 sec)
   passed  335/359  python-ts-mode-builtin-call-face (0.020583 sec)
   passed  336/359  python-ts-mode-class-patterns-face (0.004865 sec)
   passed  337/359  python-ts-mode-compound-keywords-face (0.003748 sec)
   passed  338/359  python-ts-mode-disabled-string-interpolation (0.001736 sec)
   passed  339/359  python-ts-mode-dotted-decorator-face-1 (0.001627 sec)
   passed  340/359  python-ts-mode-dotted-decorator-face-2 (0.001935 sec)
   passed  341/359  python-ts-mode-interpolation-doc-string (0.001616 sec)
   passed  342/359  python-ts-mode-interpolation-nested-string (0.001567 sec)
   passed  343/359  python-ts-mode-isinstance-type-face-1 (0.001685 sec)
   passed  344/359  python-ts-mode-isinstance-type-face-2 (0.001532 sec)
   passed  345/359  python-ts-mode-isinstance-type-face-3 (0.001694 sec)
   passed  346/359  python-ts-mode-level-fontification-wo-interpolation (0.001645 sec)
   passed  347/359  python-ts-mode-named-assignement-face-1 (0.001592 sec)
   passed  348/359  python-ts-mode-nested-types-face-1 (0.001762 sec)
   passed  349/359  python-ts-mode-superclass-type-face (0.002862 sec)
   passed  350/359  python-ts-mode-types-face-1 (0.002398 sec)
   passed  351/359  python-ts-mode-types-face-2 (0.002358 sec)
   passed  352/359  python-ts-mode-types-face-3 (0.001756 sec)
   passed  353/359  python-ts-mode-union-types-face-1 (0.001789 sec)
   passed  354/359  python-ts-mode-union-types-face-2 (0.001870 sec)
   passed  355/359  python-util-clone-local-variables-1 (0.001066 sec)
   passed  356/359  python-util-forward-comment-1 (0.001229 sec)
   passed  357/359  python-util-goto-line-1 (0.000335 sec)
   passed  358/359  python-util-strip-string-1 (0.000231 sec)
   passed  359/359  python-util-valid-regexp-p-1 (0.000080 sec)

Ran 359 tests, 350 results as expected, 7 unexpected, 2 skipped (2024-05-26 12:40:01+0200, 14.810718 sec)
3 expected failures

7 unexpected results:
   FAILED  python-completion-at-point-1
   FAILED  python-completion-at-point-2
   FAILED  python-completion-at-point-native-1
   FAILED  python-completion-at-point-native-2
   FAILED  python-completion-at-point-native-with-eldoc-1
   FAILED  python-completion-at-point-native-with-ffap-1
   FAILED  python-shell-completion-at-point-1

2 skipped results:
  SKIPPED  python-shell-completion-at-point-ipython
  SKIPPED  python-shell-completion-at-point-jedi-completer

^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  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 15:36   ` Eli Zaretskii
  1 sibling, 1 reply; 49+ messages in thread
From: kobarity @ 2024-05-26 12:05 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: Eli Zaretskii, Lin Sun, stefankangas, 70815

Mattias Engdegård wrote:
> This change caused python-tests failures on macOS. See attached log.
> 
> On this machine which has the standard macOS Python installation, 'python' is python 2, which apparently the tests don't cope very well with. (Have you verified that they do?)
> 
> The tests pass if modified to prefer Python 3:
> 
> @@ -3722,2 +3722,2 @@ python-tests-get-shell-interpreter
> -              (cl-some #'executable-find '("python" "python3" "python2"))))))
> +              (cl-some #'executable-find '("python3" "python" "python2"))))))

All ERTs pass with Python 2 on Linux (Ubuntu 22.04).  So it seems to
me that this is an issue with Python 2 on Mac.  Maybe the workaround
using "tty.setraw(0)" is not working with Python 2 on Mac?  Could you
test if the native completion is working with Python 2?





^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-26 12:05   ` kobarity
@ 2024-05-26 12:21     ` Mattias Engdegård
  2024-05-26 12:36       ` kobarity
  0 siblings, 1 reply; 49+ messages in thread
From: Mattias Engdegård @ 2024-05-26 12:21 UTC (permalink / raw)
  To: kobarity; +Cc: Eli Zaretskii, Lin Sun, stefankangas, 70815

26 maj 2024 kl. 14.05 skrev kobarity <kobarity@gmail.com>:

> All ERTs pass with Python 2 on Linux (Ubuntu 22.04).  So it seems to
> me that this is an issue with Python 2 on Mac.  Maybe the workaround
> using "tty.setraw(0)" is not working with Python 2 on Mac?  Could you
> test if the native completion is working with Python 2?

Not sure how to test that, but if I run python 2 interactively from a terminal then no completion appears to be active (although I'm not sure if something could make it work).

Given the status of Python 2 in general and on macOS in particular (there is a warning that it is only present for compatibility with legacy software) this is not very surprising. I don't think it's something we need to fix in Emacs.

Is there a reason not to apply the suggested patch to prefer `python3` to `python`?
Or put differently, why would `python-shell-interpreter` and `python-tests-get-shell-interpreter` use different preferences?






^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-26 12:21     ` Mattias Engdegård
@ 2024-05-26 12:36       ` kobarity
  2024-05-26 13:23         ` Mattias Engdegård
  0 siblings, 1 reply; 49+ messages in thread
From: kobarity @ 2024-05-26 12:36 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: Eli Zaretskii, Lin Sun, stefankangas, 70815

Mattias Engdegård wrote:
> 
> 26 maj 2024 kl. 14.05 skrev kobarity <kobarity@gmail.com>:
> 
> > All ERTs pass with Python 2 on Linux (Ubuntu 22.04).  So it seems to
> > me that this is an issue with Python 2 on Mac.  Maybe the workaround
> > using "tty.setraw(0)" is not working with Python 2 on Mac?  Could you
> > test if the native completion is working with Python 2?
> 
> Not sure how to test that, but if I run python 2 interactively from a terminal then no completion appears to be active (although I'm not sure if something could make it work).

Sorry, I forgot that native completion does not work on Mac, even with
Python 3.  What I wanted to know is if there is unexpected echo backs
with Python 2 on Mac.

> Given the status of Python 2 in general and on macOS in particular (there is a warning that it is only present for compatibility with legacy software) this is not very surprising. I don't think it's something we need to fix in Emacs.

I agree.

> Is there a reason not to apply the suggested patch to prefer `python3` to `python`?
> Or put differently, why would `python-shell-interpreter` and `python-tests-get-shell-interpreter` use different preferences?

Maybe it is better to prefer "python3", but I don't know if that would
reliably prevent the problem.  The best way would be to skip some
tests if the selected interpreter is Python 2 and it is running on
Mac.





^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-26 12:36       ` kobarity
@ 2024-05-26 13:23         ` Mattias Engdegård
  2024-05-26 14:15           ` kobarity
  2024-05-26 15:52           ` Eli Zaretskii
  0 siblings, 2 replies; 49+ messages in thread
From: Mattias Engdegård @ 2024-05-26 13:23 UTC (permalink / raw)
  To: kobarity; +Cc: Eli Zaretskii, Lin Sun, stefankangas, 70815

26 maj 2024 kl. 14.36 skrev kobarity <kobarity@gmail.com>:

> Sorry, I forgot that native completion does not work on Mac, even with
> Python 3.  What I wanted to know is if there is unexpected echo backs
> with Python 2 on Mac.

Not that I can see when running an interactive Python shell in Emacs, no.

> Maybe it is better to prefer "python3", but I don't know if that would
> reliably prevent the problem.  The best way would be to skip some
> tests if the selected interpreter is Python 2 and it is running on
> Mac.

Why select Python 2 in the first place? Is it more important to test Python 2 than Python 3 on other platforms?






^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-26 13:23         ` Mattias Engdegård
@ 2024-05-26 14:15           ` kobarity
  2024-05-26 15:00             ` kobarity
  2024-05-26 15:56             ` Eli Zaretskii
  2024-05-26 15:52           ` Eli Zaretskii
  1 sibling, 2 replies; 49+ messages in thread
From: kobarity @ 2024-05-26 14:15 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: Eli Zaretskii, Lin Sun, stefankangas, 70815

Mattias Engdegård wrote:
> 
> 26 maj 2024 kl. 14.36 skrev kobarity <kobarity@gmail.com>:
> 
> > Sorry, I forgot that native completion does not work on Mac, even with
> > Python 3.  What I wanted to know is if there is unexpected echo backs
> > with Python 2 on Mac.
> 
> Not that I can see when running an interactive Python shell in Emacs, no.

Could you see what is returned when you enter the following line in
Inferior Python buffer running Python 2 on Mac?

__PYTHON_EL_eval("print(\"Hello\")\n", "")

> > Maybe it is better to prefer "python3", but I don't know if that would
> > reliably prevent the problem.  The best way would be to skip some
> > tests if the selected interpreter is Python 2 and it is running on
> > Mac.
> 
> Why select Python 2 in the first place? Is it more important to test Python 2 than Python 3 on other platforms?

I am not saying that Python 2 (or simple "python") should be the
first.  I do agree that "python3" should be preferred than "python".

My point is that we cannot assure that Python 2 is not selected.  One
example is EMACS_PYTHON_INTERPRETER environment variable introduced by
the patch.  It can specify the interpreter used in ERTs.  So a Mac
user may set EMACS_PYTHON_INTERPRETER to "python".

I wrote in the previous mail:

> 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.

At the time of writing, I assumed that current ERTs can be run on both
Python 2 and 3 on all platforms.  However, it turned out that it was
wrong.  Some tests fail with Python 2 on Mac.  So I think we need some
mechanism to skip test based on the interpreter version and the
platform.





^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-26 14:15           ` kobarity
@ 2024-05-26 15:00             ` kobarity
  2024-05-26 15:24               ` Mattias Engdegård
  2024-05-26 15:56             ` Eli Zaretskii
  1 sibling, 1 reply; 49+ messages in thread
From: kobarity @ 2024-05-26 15:00 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: Eli Zaretskii, Lin Sun, stefankangas, 70815

kobarity wrote:
> 
> Mattias Engdegård wrote:
> > 
> > 26 maj 2024 kl. 14.36 skrev kobarity <kobarity@gmail.com>:
> > 
> > > Sorry, I forgot that native completion does not work on Mac, even with
> > > Python 3.  What I wanted to know is if there is unexpected echo backs
> > > with Python 2 on Mac.
> > 
> > Not that I can see when running an interactive Python shell in Emacs, no.
> 
> Could you see what is returned when you enter the following line in
> Inferior Python buffer running Python 2 on Mac?
> 
> __PYTHON_EL_eval("print(\"Hello\")\n", "")

Sorry, it was meaningless.
Please try evaluating the following expression in the Python buffer
after invoking Inferior Python buffer running Python 2.

(python-shell-send-string-no-output "print('a')")

Expected value is "a", but I suspect that this is not the case with
Python 2 on Mac.





^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-26 15:00             ` kobarity
@ 2024-05-26 15:24               ` Mattias Engdegård
  2024-05-27 12:33                 ` kobarity
  0 siblings, 1 reply; 49+ messages in thread
From: Mattias Engdegård @ 2024-05-26 15:24 UTC (permalink / raw)
  To: kobarity; +Cc: Eli Zaretskii, Lin Sun, stefankangas, 70815

26 maj 2024 kl. 17.00 skrev kobarity <kobarity@gmail.com>:

> Please try evaluating the following expression in the Python buffer
> after invoking Inferior Python buffer running Python 2.
> 
> (python-shell-send-string-no-output "print('a')")

The result is "a".

> My point is that we cannot assure that Python 2 is not selected.  One
> example is EMACS_PYTHON_INTERPRETER environment variable introduced by
> the patch.  It can specify the interpreter used in ERTs.  So a Mac
> user may set EMACS_PYTHON_INTERPRETER to "python".

Fair enough. I take no great interest in making the tests pass with such an environment variable assignment; at the very minimum, they should pass in the default configuration.

> So I think we need some
> mechanism to skip test based on the interpreter version and the
> platform.

Time permitting, I will be happy to run instrumented test runs if it would help you find out exactly why the test fail with Python 2.






^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-26 10:52 ` Mattias Engdegård
  2024-05-26 12:05   ` kobarity
@ 2024-05-26 15:36   ` Eli Zaretskii
  1 sibling, 0 replies; 49+ messages in thread
From: Eli Zaretskii @ 2024-05-26 15:36 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: kobarity, sunlin7.mail, stefankangas, 70815

> From: Mattias Engdegård <mattias.engdegard@gmail.com>
> Date: Sun, 26 May 2024 12:52:54 +0200
> Cc: Lin Sun <sunlin7.mail@gmail.com>,
>  stefankangas@gmail.com,
>  70815@debbugs.gnu.org,
>  Eli Zaretskii <eliz@gnu.org>
> 
> This change caused python-tests failures on macOS. See attached log.
> 
> On this machine which has the standard macOS Python installation, 'python' is python 2, which apparently the tests don't cope very well with. (Have you verified that they do?)
> 
> The tests pass if modified to prefer Python 3:
> 
> @@ -3722,2 +3722,2 @@ python-tests-get-shell-interpreter
> -              (cl-some #'executable-find '("python" "python3" "python2"))))))
> +              (cl-some #'executable-find '("python3" "python" "python2"))))))

I don't like this preference.  It is basically wrong, because it
second-guesses what Python is _the_ Python on the user's machine.

Let's try to find another solution.  If worse comes to worst, we could
make a change specific to macOS, but I hope we won't need to.





^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-26 13:23         ` Mattias Engdegård
  2024-05-26 14:15           ` kobarity
@ 2024-05-26 15:52           ` Eli Zaretskii
  2024-05-27 10:24             ` Mattias Engdegård
  1 sibling, 1 reply; 49+ messages in thread
From: Eli Zaretskii @ 2024-05-26 15:52 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: kobarity, sunlin7.mail, stefankangas, 70815

> From: Mattias Engdegård <mattias.engdegard@gmail.com>
> Date: Sun, 26 May 2024 15:23:46 +0200
> Cc: Lin Sun <sunlin7.mail@gmail.com>,
>  stefankangas@gmail.com,
>  70815@debbugs.gnu.org,
>  Eli Zaretskii <eliz@gnu.org>
> 
> Why select Python 2 in the first place? Is it more important to test Python 2 than Python 3 on other platforms?

Why do you have "python" as python2 when you have Python 3.x
installed?  The usual practice is to have "python" invoke the
preferred version, which is normally the latest one.





^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-26 14:15           ` kobarity
  2024-05-26 15:00             ` kobarity
@ 2024-05-26 15:56             ` Eli Zaretskii
  2024-05-26 23:06               ` Stefan Kangas
  1 sibling, 1 reply; 49+ messages in thread
From: Eli Zaretskii @ 2024-05-26 15:56 UTC (permalink / raw)
  To: kobarity; +Cc: mattias.engdegard, sunlin7.mail, stefankangas, 70815

> Date: Sun, 26 May 2024 23:15:50 +0900
> From: kobarity <kobarity@gmail.com>
> Cc: Lin Sun <sunlin7.mail@gmail.com>,
> 	stefankangas@gmail.com,
> 	70815@debbugs.gnu.org,
> 	Eli Zaretskii <eliz@gnu.org>
> 
> > Why select Python 2 in the first place? Is it more important to test Python 2 than Python 3 on other platforms?
> 
> I am not saying that Python 2 (or simple "python") should be the
> first.  I do agree that "python3" should be preferred than "python".

I think Python 3 should be preferred if the user prefers it.  And if
the python interpreter invoked by "python" is not the preferred
version, then how can Emacs know which one is the preferred version?

> At the time of writing, I assumed that current ERTs can be run on both
> Python 2 and 3 on all platforms.  However, it turned out that it was
> wrong.  Some tests fail with Python 2 on Mac.  So I think we need some
> mechanism to skip test based on the interpreter version and the
> platform.

If macOS needs special treatment, here, we can install a change
specific to macOS.  But let's not skew all the platforms because of
macOS.





^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-26 15:56             ` Eli Zaretskii
@ 2024-05-26 23:06               ` Stefan Kangas
  2024-05-27 11:18                 ` Eli Zaretskii
  0 siblings, 1 reply; 49+ messages in thread
From: Stefan Kangas @ 2024-05-26 23:06 UTC (permalink / raw)
  To: Eli Zaretskii, kobarity; +Cc: mattias.engdegard, sunlin7.mail, 70815

Eli Zaretskii <eliz@gnu.org> writes:

> I think Python 3 should be preferred if the user prefers it.  And if
> the python interpreter invoked by "python" is not the preferred
> version, then how can Emacs know which one is the preferred version?

If we do still care about Python 2, why should we test using only _one_
version?  If both are available, surely it's better to run the test
using both.

If we don't want to do that, it makes more sense to prefer Python 3.
This given that Python 2 is EOL since 4+ years, and is less and less
likely to be relevant.

For example, RHEL 8 will stop offical support for Python 2 next month,
and RHEL 9 doesn't ship with it.  Debian GNU/Linux has already dropped
Python 2 from its stable distribution.  And so on.





^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-26 15:52           ` Eli Zaretskii
@ 2024-05-27 10:24             ` Mattias Engdegård
  2024-05-27 11:19               ` Lin Sun
  0 siblings, 1 reply; 49+ messages in thread
From: Mattias Engdegård @ 2024-05-27 10:24 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: kobarity, sunlin7.mail, stefankangas, 70815

26 maj 2024 kl. 17.52 skrev Eli Zaretskii <eliz@gnu.org>:

> Why do you have "python" as python2 when you have Python 3.x
> installed?  The usual practice is to have "python" invoke the
> preferred version, which is normally the latest one.

That is a misunderstanding. It is not at all unusual to have plain `python` being Python 2 for compatibility with old scripts. (A long-running debate point in the transition from Python 2 to 3.)

In any case, this set-up is standard in macOS (at least my version), and I'm quite sure I've seen similar arrangements in other systems.

What we are debating now is whether it is worth making the tests pass for certain Python 2 installations if the user somehow prefers those (with EMACS_PYTHON_INTERPRETER), and if so, how.

Kobarity and Lin Sun, wouldn't it make sense to tie the interpreter to test to `python-shell-interpreter`?






^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-26 23:06               ` Stefan Kangas
@ 2024-05-27 11:18                 ` Eli Zaretskii
  2024-05-27 12:20                   ` Mattias Engdegård
  0 siblings, 1 reply; 49+ messages in thread
From: Eli Zaretskii @ 2024-05-27 11:18 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: kobarity, sunlin7.mail, mattias.engdegard, 70815

> From: Stefan Kangas <stefankangas@gmail.com>
> Date: Sun, 26 May 2024 16:06:31 -0700
> Cc: mattias.engdegard@gmail.com, sunlin7.mail@gmail.com, 70815@debbugs.gnu.org
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > I think Python 3 should be preferred if the user prefers it.  And if
> > the python interpreter invoked by "python" is not the preferred
> > version, then how can Emacs know which one is the preferred version?
> 
> If we do still care about Python 2, why should we test using only _one_
> version?  If both are available, surely it's better to run the test
> using both.

We do care about Python 2 because some users still use it.  There's no
other reasons: Emacs doesn't care which version of Python is
preferable to the user.

We could test both versions if they are installed, I don't think I'd
mind.

> If we don't want to do that, it makes more sense to prefer Python 3.
> This given that Python 2 is EOL since 4+ years, and is less and less
> likely to be relevant.

Mattias's message in this thread indicates otherwise, I think.

> For example, RHEL 8 will stop offical support for Python 2 next month,
> and RHEL 9 doesn't ship with it.  Debian GNU/Linux has already dropped
> Python 2 from its stable distribution.  And so on.

Emacs doesn't need to follow these tendencies.  We try to avoid
forcing our users to upgrade unrelated or loosely-related software
just because they installed a newer version of Emacs, because forcing
them to do that in many cases ends up sending them down an immense
rabbit hole, whereby upgrading some component requires them to upgrade
many others, in a well-known snowball fashion.  So we generally decide
to drop support for some old software only when keeping it supported
becomes a real burden.

I don't think Python is a maintenance burden for us at this time, is
it?





^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-27 10:24             ` Mattias Engdegård
@ 2024-05-27 11:19               ` Lin Sun
  0 siblings, 0 replies; 49+ messages in thread
From: Lin Sun @ 2024-05-27 11:19 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: Eli Zaretskii, kobarity, 70815, Stefan Kangas

[-- Attachment #1: Type: text/plain, Size: 1463 bytes --]

On Mon, May 27, 2024, 03:24 Mattias Engdegård <mattias.engdegard@gmail.com>
wrote:

> 26 maj 2024 kl. 17.52 skrev Eli Zaretskii <eliz@gnu.org>:
>
> > Why do you have "python" as python2 when you have Python 3.x
> > installed?  The usual practice is to have "python" invoke the
> > preferred version, which is normally the latest one.
>
> That is a misunderstanding. It is not at all unusual to have plain
> `python` being Python 2 for compatibility with old scripts. (A long-running
> debate point in the transition from Python 2 to 3.)
>
> In any case, this set-up is standard in macOS (at least my version), and
> I'm quite sure I've seen similar arrangements in other systems.
>
> What we are debating now is whether it is worth making the tests pass for
> certain Python 2 installations if the user somehow prefers those (with
> EMACS_PYTHON_INTERPRETER), and if so, how.
>
> Kobarity and Lin Sun, wouldn't it make sense to tie the interpreter to
> test to `python-shell-interpreter`?
>

Hi Eli, it's not worth to make the cases for user perfers
EMACS_PYTHON_INTERPRETER.
It's failed naturally if the interpreter version is not supported anymore
or not supported yet.

For python2, as we discussed on original patch thread, it may be will still
exists for many years, so we need keep compatible with it, but we may skip
the cases that not working for python2 anymore.

And I'm trying to get the details of the failure.

>

[-- Attachment #2: Type: text/html, Size: 2186 bytes --]

^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-27 11:18                 ` Eli Zaretskii
@ 2024-05-27 12:20                   ` Mattias Engdegård
  2024-05-27 12:43                     ` Eli Zaretskii
  0 siblings, 1 reply; 49+ messages in thread
From: Mattias Engdegård @ 2024-05-27 12:20 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: kobarity, sunlin7.mail, Stefan Kangas, 70815

27 maj 2024 kl. 13.18 skrev Eli Zaretskii <eliz@gnu.org>:

>> If we don't want to do that, it makes more sense to prefer Python 3.
>> This given that Python 2 is EOL since 4+ years, and is less and less
>> likely to be relevant.
> 
> Mattias's message in this thread indicates otherwise, I think.

The `python` binary can very well be the one nobody wants to use, it's just that it has a long-term legacy lease on the file name. For example, on this system (with the unmodified system default Python installations):

|~% python
|
|WARNING: Python 2.7 is not recommended. 
|This version is included in macOS for compatibility with legacy software. 
|Future versions of macOS will not include Python 2.7. 
|Instead, it is recommended that you transition to using 'python3' from within Terminal.

I very much agree that we should make our own decision about what platforms and versions to support but in this case it's just a matter of what we want to use for testing our own code, and given more than one Python, the one named `python3` is more likely to be relevant than just `python`.







^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  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
  0 siblings, 2 replies; 49+ messages in thread
From: kobarity @ 2024-05-27 12:33 UTC (permalink / raw)
  To: Mattias Engdegård, Lin Sun; +Cc: Eli Zaretskii, Stefan Kangas, 70815

Mattias Engdegård wrote:
> > Please try evaluating the following expression in the Python buffer
> > after invoking Inferior Python buffer running Python 2.
> > 
> > (python-shell-send-string-no-output "print('a')")
> 
> The result is "a".

Thanks.  Then I have no idea why it fails.  It's difficult for me to
further investigate as I don't have Mac environment.

Mattias Engdegård wrote:
> Kobarity and Lin Sun, wouldn't it make sense to tie the interpreter to test to `python-shell-interpreter`?

I don't think it is a good idea.  `python-shell-interpreter' can be a
variety of things.  It may be IPython, PyPy, or even Poetry.
`python-tests-shell-interpreter' exists to override
`python-shell-interpreter'.

Lin Sun wrote:
> Hi Eli, it's not worth to make the cases for user perfers EMACS_PYTHON_INTERPRETER. 
> It's failed naturally if the interpreter version is not supported anymore or not supported yet.

I think we are still supporting Python 2 on Mac.  It is just that
there seems to be problems with some features.

ERTs exist to find bugs.  In that sense, I think the ERTs have worked
well.  We probably have found the bug with Python 2 on Mac, unless
there is a bug on the ERTs.  So the natural and best course is to fix
that bug.  Changing the order of the interpreters to find or skipping
some ERTs does not solve the problem.  However, it seems that only a
limited number of people can pursue the problem on Mac, and fewer
people will have trouble with Python 2 issues.  So for now, I think it
is better to skip these ERTs for Python 2 on Mac only.

The problem is that there is no convenient way to skip some ERTs based
on the interpreter's version.  I will think about it, but it will be
over the weekend at the earliest.





^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-27 12:20                   ` Mattias Engdegård
@ 2024-05-27 12:43                     ` Eli Zaretskii
  0 siblings, 0 replies; 49+ messages in thread
From: Eli Zaretskii @ 2024-05-27 12:43 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: kobarity, sunlin7.mail, stefankangas, 70815

> From: Mattias Engdegård <mattias.engdegard@gmail.com>
> Date: Mon, 27 May 2024 14:20:21 +0200
> Cc: Stefan Kangas <stefankangas@gmail.com>,
>  kobarity@gmail.com,
>  sunlin7.mail@gmail.com,
>  70815@debbugs.gnu.org
> 
> I very much agree that we should make our own decision about what platforms and versions to support but in this case it's just a matter of what we want to use for testing our own code, and given more than one Python, the one named `python3` is more likely to be relevant than just `python`.

If the Python experts agree, I won't object.

FTR, I have Python 3.x installed here, but no "python3", only
"python".





^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-27 12:33                 ` kobarity
@ 2024-05-27 12:45                   ` Eli Zaretskii
  2024-05-28 12:30                   ` Mattias Engdegård
  1 sibling, 0 replies; 49+ messages in thread
From: Eli Zaretskii @ 2024-05-27 12:45 UTC (permalink / raw)
  To: kobarity; +Cc: mattias.engdegard, sunlin7.mail, stefankangas, 70815

> Date: Mon, 27 May 2024 21:33:03 +0900
> From: kobarity <kobarity@gmail.com>
> Cc: Eli Zaretskii <eliz@gnu.org>,
> 	Stefan Kangas <stefankangas@gmail.com>,
> 	70815@debbugs.gnu.org
> 
> ERTs exist to find bugs.  In that sense, I think the ERTs have worked
> well.  We probably have found the bug with Python 2 on Mac, unless
> there is a bug on the ERTs.  So the natural and best course is to fix
> that bug.  Changing the order of the interpreters to find or skipping
> some ERTs does not solve the problem.  However, it seems that only a
> limited number of people can pursue the problem on Mac, and fewer
> people will have trouble with Python 2 issues.  So for now, I think it
> is better to skip these ERTs for Python 2 on Mac only.

I'm okay with that solution as well.





^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  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
  1 sibling, 1 reply; 49+ messages in thread
From: Mattias Engdegård @ 2024-05-28 12:30 UTC (permalink / raw)
  To: kobarity; +Cc: Eli Zaretskii, Lin Sun, Stefan Kangas, 70815

27 maj 2024 kl. 14.33 skrev kobarity <kobarity@gmail.com>:

> We probably have found the bug with Python 2 on Mac, unless
> there is a bug on the ERTs.

It could just be a mismatch of expectations. With python-shell-interpreter set to "python2", tab-completion in the Python interactive shell works but in a diminished capacity. For example, 'pri<TAB>' completes to 'print' but 'math.sq<TAB>' does not complete to 'math.sqrt(' as it does in Python 3.

> Changing the order of the interpreters to find or skipping
> some ERTs does not solve the problem.

But it does fix a different problem: it tests python-mode with Python 3, which is more important.

>  However, it seems that only a
> limited number of people can pursue the problem on Mac, and fewer
> people will have trouble with Python 2 issues.  So for now, I think it
> is better to skip these ERTs for Python 2 on Mac only.

We can probably agree that absent explicit information about what version the user wants tested, we should test python-mode with Python 3 on macOS and other platforms.

If you think it is important we can also test it with Python 2 if available. Rejigging the tests to run for multiple Python versions is certainly possible but would be some work.

Meanwhile I'm just going to make the tests use the same logic as python.el for selecting the binary to use, as there does not seem to be a reason why this would make anything worse.






^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-28 12:30                   ` Mattias Engdegård
@ 2024-05-28 15:17                     ` kobarity
  2024-05-28 16:09                       ` Mattias Engdegård
  0 siblings, 1 reply; 49+ messages in thread
From: kobarity @ 2024-05-28 15:17 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: Eli Zaretskii, Lin Sun, Stefan Kangas, 70815

Mattias Engdegård wrote:
> 
> 27 maj 2024 kl. 14.33 skrev kobarity <kobarity@gmail.com>:
> 
> > We probably have found the bug with Python 2 on Mac, unless
> > there is a bug on the ERTs.
> 
> It could just be a mismatch of expectations. With python-shell-interpreter set to "python2", tab-completion in the Python interactive shell works but in a diminished capacity. For example, 'pri<TAB>' completes to 'print' but 'math.sq<TAB>' does not complete to 'math.sqrt(' as it does in Python 3.

I think it is a "bug".  Because it is working with Python 2 on Linux
(with native and non-native completions), and I believe many would
expect it to work.

In any case, to accommodate the ERTs for such differences, a mechanism
to skip an ERT based on the interpreter version (or some other
property) is needed.

> > Changing the order of the interpreters to find or skipping
> > some ERTs does not solve the problem.
> 
> But it does fix a different problem: it tests python-mode with Python 3, which is more important.

As I mentioned before, I am not opposed to prioritize "python3".  I
don't think anyone is arguing that "python" should precede "python3"
anymore.

> >  However, it seems that only a
> > limited number of people can pursue the problem on Mac, and fewer
> > people will have trouble with Python 2 issues.  So for now, I think it
> > is better to skip these ERTs for Python 2 on Mac only.
> 
> We can probably agree that absent explicit information about what version the user wants tested, we should test python-mode with Python 3 on macOS and other platforms.
> 
> If you think it is important we can also test it with Python 2 if available. Rejigging the tests to run for multiple Python versions is certainly possible but would be some work.
> 
> Meanwhile I'm just going to make the tests use the same logic as python.el for selecting the binary to use, as there does not seem to be a reason why this would make anything worse.
> 

You have an option to set EMACS_PYTHON_INTERPRETER environment
variable to "python3", just for now.





^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-28 15:17                     ` kobarity
@ 2024-05-28 16:09                       ` Mattias Engdegård
  2024-05-29 14:56                         ` kobarity
  0 siblings, 1 reply; 49+ messages in thread
From: Mattias Engdegård @ 2024-05-28 16:09 UTC (permalink / raw)
  To: kobarity; +Cc: Eli Zaretskii, Lin Sun, Stefan Kangas, 70815

28 maj 2024 kl. 17.17 skrev kobarity <kobarity@gmail.com>:

> I think it is a "bug".  Because it is working with Python 2 on Linux
> (with native and non-native completions), and I believe many would
> expect it to work.

Could be, but it's hard to believe that whatever completion defect we have in python.el for Python 2 on macOS is affecting a lot of people. It seems usable enough to me, given the circumstances.

> As I mentioned before, I am not opposed to prioritize "python3".  I
> don't think anyone is arguing that "python" should precede "python3"
> anymore.

Thank you. I don't want to steamroller a change, but there is a real risk of paralysis from too much deference to code details that might just as well have been a simple oversight, which I believe is what happened here.

And again, I'd be happy to help debug the problem on macOS if someone is very bothered about the problem now or in the future.






^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-28 16:09                       ` Mattias Engdegård
@ 2024-05-29 14:56                         ` kobarity
  2024-05-30 10:09                           ` Mattias Engdegård
  0 siblings, 1 reply; 49+ messages in thread
From: kobarity @ 2024-05-29 14:56 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: Eli Zaretskii, Lin Sun, Stefan Kangas, 70815

Mattias Engdegård wrote:
> 28 maj 2024 kl. 17.17 skrev kobarity <kobarity@gmail.com>:
> 
> > I think it is a "bug".  Because it is working with Python 2 on Linux
> > (with native and non-native completions), and I believe many would
> > expect it to work.
> 
> Could be, but it's hard to believe that whatever completion defect we have in python.el for Python 2 on macOS is affecting a lot of people. It seems usable enough to me, given the circumstances.
> 
> > As I mentioned before, I am not opposed to prioritize "python3".  I
> > don't think anyone is arguing that "python" should precede "python3"
> > anymore.
> 
> Thank you. I don't want to steamroller a change, but there is a real risk of paralysis from too much deference to code details that might just as well have been a simple oversight, which I believe is what happened here.

I'm not sure what you are proposing.  What I want to do now is not to
fix the "bug", but to accept the current situation and express it as
the ERTs.  Otherwise, even if we change the order of the interpreters,
it will fail when some Mac user sets EMACS_PYTHON_INTERPRETER to
"python" and runs ERTs for example.

Even if we could fix this "bug" right away, or even if we made the
decision to stop Python 2 support on Mac, I believe we would still
need a mechanism to skip an ERT based on the interpreter version
because similar stories would still come up.

Unless you are opposed to adding such a mechanism to ERT, I don't see
much difference of opinion between us.  If you want to change the
order of the interpreters as soon as possible, I am not opposed to
that either.





^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-29 14:56                         ` kobarity
@ 2024-05-30 10:09                           ` Mattias Engdegård
  2024-06-02 13:20                             ` kobarity
  0 siblings, 1 reply; 49+ messages in thread
From: Mattias Engdegård @ 2024-05-30 10:09 UTC (permalink / raw)
  To: kobarity; +Cc: Eli Zaretskii, Lin Sun, Stefan Kangas, 70815

29 maj 2024 kl. 16.56 skrev kobarity <kobarity@gmail.com>:

> What I want to do now is not to
> fix the "bug", but to accept the current situation and express it as
> the ERTs.  Otherwise, even if we change the order of the interpreters,
> it will fail when some Mac user sets EMACS_PYTHON_INTERPRETER to
> "python" and runs ERTs for example.

That's very generous of you but watch out so that you don't waste time on busywork that isn't strictly necessary.

I did adjust the order of the interpreters in 9c7de10079, by the way; that took care of my own itches for this bug.

Do whatever you feel is necessary but again, your own time is precious.






^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-05-30 10:09                           ` Mattias Engdegård
@ 2024-06-02 13:20                             ` kobarity
  2024-06-03 14:02                               ` Mattias Engdegård
  0 siblings, 1 reply; 49+ messages in thread
From: kobarity @ 2024-06-02 13:20 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: Eli Zaretskii, Lin Sun, Stefan Kangas, 70815

[-- Attachment #1: Type: text/plain, Size: 1648 bytes --]

Mattias Engdegård wrote:
> 29 maj 2024 kl. 16.56 skrev kobarity <kobarity@gmail.com>:
> 
> > What I want to do now is not to
> > fix the "bug", but to accept the current situation and express it as
> > the ERTs.  Otherwise, even if we change the order of the interpreters,
> > it will fail when some Mac user sets EMACS_PYTHON_INTERPRETER to
> > "python" and runs ERTs for example.
> 
> That's very generous of you but watch out so that you don't waste time on busywork that isn't strictly necessary.
> 
> I did adjust the order of the interpreters in 9c7de10079, by the way; that took care of my own itches for this bug.
> 
> Do whatever you feel is necessary but again, your own time is precious.

Thanks, but as I mentioned before, this is something I thought we
would need sooner or later, even before the bug was found.

The attached patch is my proposal.  I added PRED argument to
`python-tests-get-shell-interpreter' to allow conditions to be
specified when selecting an interpreter.  For now, I only provide a
predicate that the major version of the interpreter is 3, but I think
it would be easy to add.

It would be helpful if you could try each of the following on Mac.

1. Set EMACS_PYTHON_INTERPRETER environment variable to "python" and
   run ERTs.  The expectation is that the 7 ERTs that previously
   resulted in errors will be skipped.
2. Revert 9c7de10079 and run ERTs.  The expectation is that the 7 ERTs
   that previously failed will succeed.

BTW, Apple seems to have removed Python 2 in 2022 MacOS 12.3.  Is your
Python 2 installed with brew or something else? Or is it an old Apple
one?

[-- Attachment #2: 0001-Specify-Python-3-in-some-ERTs-on-Mac.patch --]
[-- Type: application/octet-stream, Size: 7744 bytes --]

From e7e40853ea7f310aab50f223ecf17fe7cbf123e8 Mon Sep 17 00:00:00 2001
From: kobarity <kobarity@gmail.com>
Date: Sun, 2 Jun 2024 22:14:07 +0900
Subject: [PATCH] Specify Python 3 in some ERTs on Mac

* test/lisp/progmodes/python-tests.el (cl-extra): Remove
require.
(python-tests-shell-interpreter): Removed.
(python-tests-shell-interpreters): New variable.
(python-tests-get-shell-interpreter): Add an optional PRED
argument to allow ERts to specify Python interpreter version.
(python-tests--get-interpreter-info): New function.
(python-tests-interpreter-3-p): New function to be used as the
PRED argument of 'python-tests-get-shell-interpreter'.
(python-shell-completion-at-point-ipython): Remove setting
'python-tests-shell-interpreter'.
(python-shell-completion-at-point-1)
(python-completion-at-point-1)
(python-completion-at-point-2)
(python-completion-at-point-native-1)
(python-completion-at-point-native-2)
(python-completion-at-point-native-with-ffap-1)
(python-completion-at-point-native-with-eldoc-1): Specify
Python 3 on Mac to avoid errors.  (Bug#70815)
---
 test/lisp/progmodes/python-tests.el | 76 ++++++++++++++++++++---------
 1 file changed, 54 insertions(+), 22 deletions(-)

diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
index b06547b10ff..970ec32bc0c 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -3750,21 +3750,47 @@ python-bob-infloop-avoid
 \f
 ;;; Shell integration
 
-(defvar python-tests-shell-interpreter nil)
+(defvar python-tests-shell-interpreters nil
+  "List of Python interpreter information.
+Set this variable to nil to rescan interpreters.")
 
-(defun python-tests-get-shell-interpreter ()
+(defun python-tests-get-shell-interpreter (&optional pred)
   "Get the shell interpreter.
-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
-          (or (when-let ((interpreter (getenv "EMACS_PYTHON_INTERPRETER")))
-                (or (executable-find interpreter)
-                    (error "Couldn't find EMACS_PYTHON_INTERPRETER(%s) in path"
-                           interpreter)))
-              ;; Use the same order as for the default value of
-              ;; `python-shell-interpreter'.
-              (cl-some #'executable-find '("python3" "python" "python2"))))))
+If an optional PRED is specified, an interpreter is selected that
+matches the predicate.  PRED must return the absolute file name if the
+condition is met.  If env string EMACS_PYTHON_INTERPRETER exists, use it
+as preferred one."
+  (unless python-tests-shell-interpreters
+    (setq python-tests-shell-interpreters
+          (if-let ((interpreter (getenv "EMACS_PYTHON_INTERPRETER")))
+              (if-let ((info (python-tests--get-interpreter-info interpreter)))
+                  (list info)
+                (error "Couldn't find EMACS_PYTHON_INTERPRETER(%s) in path"
+                       interpreter))
+            ;; Use the same order as for the default value of
+            ;; `python-shell-interpreter'.
+            (delq nil (mapcar #'python-tests--get-interpreter-info
+                              '("python3" "python" "python2"))))))
+  (cl-some (or pred #'car) python-tests-shell-interpreters))
+
+(defun python-tests--get-interpreter-info (name)
+  "Get Python interpreter information specified by NAME.
+The information returned is a cons cell consisting of the file path and
+the version string."
+  (when-let ((interpreter (executable-find name)))
+    (with-temp-buffer
+      (and (equal (call-process interpreter nil t nil "--version") 0)
+           (goto-char (point-min))
+           (looking-at
+            (rx (seq "Python" (+ space) (group (+ (any digit ?.))))))
+           (cons interpreter (match-string-no-properties 1))))))
+
+(defun python-tests-interpreter-3-p (info)
+  "Return the absolute file name if the interpreter major version in INFO is 3.
+This function is intended to be used as the PRED argument of
+`python-tests-get-shell-interpreter'."
+  (when (string= (car (split-string (cdr info) "\\.")) "3")
+    (car info)))
 
 (ert-deftest python-shell-get-process-name-1 ()
   "Check process name calculation sans `buffer-file-name'."
@@ -4828,7 +4854,8 @@ python-shell-completion-native-interpreter-disabled-p-1
     (should (python-shell-completion-native-interpreter-disabled-p))))
 
 (ert-deftest python-shell-completion-at-point-1 ()
-  (skip-unless (python-tests-get-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter
+                (when (eq system-type 'darwin) #'python-tests-interpreter-3-p)))
   (python-tests-with-temp-buffer-with-shell
    ""
    (python-shell-with-shell-buffer
@@ -4945,8 +4972,7 @@ python-shell-completion-at-point-jedi-completer
 
 (ert-deftest python-shell-completion-at-point-ipython ()
   "Check if Python shell completion works for IPython."
-  (let ((python-tests-shell-interpreter "ipython")
-        (python-shell-interpreter "ipython")
+  (let ((python-shell-interpreter "ipython")
         (python-shell-interpreter-args "-i --simple-prompt"))
     (skip-unless
      (and
@@ -4973,7 +4999,8 @@ python-shell-completion-at-point-ipython
 ;;; Symbol completion
 
 (ert-deftest python-completion-at-point-1 ()
-  (skip-unless (python-tests-get-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter
+                (when (eq system-type 'darwin) #'python-tests-interpreter-3-p)))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -4991,7 +5018,8 @@ python-completion-at-point-1
 
 (ert-deftest python-completion-at-point-2 ()
   "Should work regardless of the point in the Shell buffer."
-  (skip-unless (python-tests-get-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter
+                (when (eq system-type 'darwin) #'python-tests-interpreter-3-p)))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -5044,7 +5072,8 @@ python-completion-at-point-while-running-1
      (should-not (with-timeout (1 t) (completion-at-point))))))
 
 (ert-deftest python-completion-at-point-native-1 ()
-  (skip-unless (python-tests-get-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter
+                (when (eq system-type 'darwin) #'python-tests-interpreter-3-p)))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -5063,7 +5092,8 @@ python-completion-at-point-native-1
 
 (ert-deftest python-completion-at-point-native-2 ()
   "Should work regardless of the point in the Shell buffer."
-  (skip-unless (python-tests-get-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter
+                (when (eq system-type 'darwin) #'python-tests-interpreter-3-p)))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -5081,7 +5111,8 @@ python-completion-at-point-native-2
      (should (completion-at-point)))))
 
 (ert-deftest python-completion-at-point-native-with-ffap-1 ()
-  (skip-unless (python-tests-get-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter
+                (when (eq system-type 'darwin) #'python-tests-interpreter-3-p)))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
@@ -5099,7 +5130,8 @@ python-completion-at-point-native-with-ffap-1
      (should (completion-at-point)))))
 
 (ert-deftest python-completion-at-point-native-with-eldoc-1 ()
-  (skip-unless (python-tests-get-shell-interpreter))
+  (skip-unless (python-tests-get-shell-interpreter
+                (when (eq system-type 'darwin) #'python-tests-interpreter-3-p)))
   (python-tests-with-temp-buffer-with-shell
    "
 import abc
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-06-02 13:20                             ` kobarity
@ 2024-06-03 14:02                               ` Mattias Engdegård
  2024-06-03 14:34                                 ` kobarity
  0 siblings, 1 reply; 49+ messages in thread
From: Mattias Engdegård @ 2024-06-03 14:02 UTC (permalink / raw)
  To: kobarity; +Cc: Eli Zaretskii, Lin Sun, Stefan Kangas, 70815

2 juni 2024 kl. 15.20 skrev kobarity <kobarity@gmail.com>:

> The attached patch is my proposal.  I added PRED argument to
> `python-tests-get-shell-interpreter' to allow conditions to be
> specified when selecting an interpreter.  For now, I only provide a
> predicate that the major version of the interpreter is 3, but I think
> it would be easy to add.

That would work for me. (It could maybe be simplified a bit but that's not very important.)

> 1. Set EMACS_PYTHON_INTERPRETER environment variable to "python" and
>   run ERTs.  The expectation is that the 7 ERTs that previously
>   resulted in errors will be skipped.

With EMACS_PYTHON_INTERPRETER=python3 or unset

  SKIPPED  python-shell-completion-at-point-ipython
  SKIPPED  python-shell-completion-at-point-jedi-completer

With EMACS_PYTHON_INTERPRETER=python

  SKIPPED  python-completion-at-point-1
  SKIPPED  python-completion-at-point-2
  SKIPPED  python-completion-at-point-native-1
  SKIPPED  python-completion-at-point-native-2
  SKIPPED  python-completion-at-point-native-with-eldoc-1
  SKIPPED  python-completion-at-point-native-with-ffap-1
  SKIPPED  python-shell-completion-at-point-1
  SKIPPED  python-shell-completion-at-point-ipython
  SKIPPED  python-shell-completion-at-point-jedi-completer

> 2. Revert 9c7de10079 and run ERTs.  The expectation is that the 7 ERTs
>   that previously failed will succeed.

No, they still fail:

7 unexpected results:
   FAILED  python-completion-at-point-1
   FAILED  python-completion-at-point-2
   FAILED  python-completion-at-point-native-1
   FAILED  python-completion-at-point-native-2
   FAILED  python-completion-at-point-native-with-eldoc-1
   FAILED  python-completion-at-point-native-with-ffap-1
   FAILED  python-shell-completion-at-point-1

2 skipped results:
  SKIPPED  python-shell-completion-at-point-ipython
  SKIPPED  python-shell-completion-at-point-jedi-completer

> Apple seems to have removed Python 2 in 2022 MacOS 12.3.  Is your
> Python 2 installed with brew or something else? Or is it an old Apple
> one?

It's the standard setup of an older version of macOS (the hardware of that machine can't run 12.3).






^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-06-03 14:02                               ` Mattias Engdegård
@ 2024-06-03 14:34                                 ` kobarity
  2024-06-03 16:24                                   ` kobarity
  0 siblings, 1 reply; 49+ messages in thread
From: kobarity @ 2024-06-03 14:34 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: Eli Zaretskii, Lin Sun, Stefan Kangas, 70815

Mattias Engdegård wrote:
> 2 juni 2024 kl. 15.20 skrev kobarity <kobarity@gmail.com>:
> > 1. Set EMACS_PYTHON_INTERPRETER environment variable to "python" and
> >   run ERTs.  The expectation is that the 7 ERTs that previously
> >   resulted in errors will be skipped.
> 
> With EMACS_PYTHON_INTERPRETER=python3 or unset
> 
>   SKIPPED  python-shell-completion-at-point-ipython
>   SKIPPED  python-shell-completion-at-point-jedi-completer
> 
> With EMACS_PYTHON_INTERPRETER=python
> 
>   SKIPPED  python-completion-at-point-1
>   SKIPPED  python-completion-at-point-2
>   SKIPPED  python-completion-at-point-native-1
>   SKIPPED  python-completion-at-point-native-2
>   SKIPPED  python-completion-at-point-native-with-eldoc-1
>   SKIPPED  python-completion-at-point-native-with-ffap-1
>   SKIPPED  python-shell-completion-at-point-1
>   SKIPPED  python-shell-completion-at-point-ipython
>   SKIPPED  python-shell-completion-at-point-jedi-completer

Thanks, this is as expected.

> > 2. Revert 9c7de10079 and run ERTs.  The expectation is that the 7 ERTs
> >   that previously failed will succeed.
> 
> No, they still fail:
> 
> 7 unexpected results:
>    FAILED  python-completion-at-point-1
>    FAILED  python-completion-at-point-2
>    FAILED  python-completion-at-point-native-1
>    FAILED  python-completion-at-point-native-2
>    FAILED  python-completion-at-point-native-with-eldoc-1
>    FAILED  python-completion-at-point-native-with-ffap-1
>    FAILED  python-shell-completion-at-point-1
> 
> 2 skipped results:
>   SKIPPED  python-shell-completion-at-point-ipython
>   SKIPPED  python-shell-completion-at-point-jedi-completer

Maybe I did not make the right request.  What I wanted you to try was
to make the following changes after applying my patch in the previous
email.

diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
index 970ec32bc0c..77b30f8bdbc 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -3770,7 +3770,7 @@ python-tests-get-shell-interpreter
             ;; Use the same order as for the default value of
             ;; `python-shell-interpreter'.
             (delq nil (mapcar #'python-tests--get-interpreter-info
-                              '("python3" "python" "python2"))))))
+                              '("python" "python3" "python2"))))))
   (cl-some (or pred #'car) python-tests-shell-interpreters))

 (defun python-tests--get-interpreter-info (name)

If you have tried it this way, could you tell me what the value of
`python-tests-shell-interpreters' is?

> > Apple seems to have removed Python 2 in 2022 MacOS 12.3.  Is your
> > Python 2 installed with brew or something else? Or is it an old Apple
> > one?
> 
> It's the standard setup of an older version of macOS (the hardware of that machine can't run 12.3).

I understood.





^ permalink raw reply related	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-06-03 14:34                                 ` kobarity
@ 2024-06-03 16:24                                   ` kobarity
  2024-06-04 14:29                                     ` kobarity
  0 siblings, 1 reply; 49+ messages in thread
From: kobarity @ 2024-06-03 16:24 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: Eli Zaretskii, Lin Sun, Stefan Kangas, 70815

kobarity wrote:
> Mattias Engdegård wrote:
> > > 2. Revert 9c7de10079 and run ERTs.  The expectation is that the 7 ERTs
> > >   that previously failed will succeed.
> > 
> > No, they still fail:
> > 
> > 7 unexpected results:
> >    FAILED  python-completion-at-point-1
> >    FAILED  python-completion-at-point-2
> >    FAILED  python-completion-at-point-native-1
> >    FAILED  python-completion-at-point-native-2
> >    FAILED  python-completion-at-point-native-with-eldoc-1
> >    FAILED  python-completion-at-point-native-with-ffap-1
> >    FAILED  python-shell-completion-at-point-1
> > 
> > 2 skipped results:
> >   SKIPPED  python-shell-completion-at-point-ipython
> >   SKIPPED  python-shell-completion-at-point-jedi-completer
> 
> Maybe I did not make the right request.  What I wanted you to try was
> to make the following changes after applying my patch in the previous
> email.
> 
> diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
> index 970ec32bc0c..77b30f8bdbc 100644
> --- a/test/lisp/progmodes/python-tests.el
> +++ b/test/lisp/progmodes/python-tests.el
> @@ -3770,7 +3770,7 @@ python-tests-get-shell-interpreter
>              ;; Use the same order as for the default value of
>              ;; `python-shell-interpreter'.
>              (delq nil (mapcar #'python-tests--get-interpreter-info
> -                              '("python3" "python" "python2"))))))
> +                              '("python" "python3" "python2"))))))
>    (cl-some (or pred #'car) python-tests-shell-interpreters))
> 
>  (defun python-tests--get-interpreter-info (name)
> 
> If you have tried it this way, could you tell me what the value of
> `python-tests-shell-interpreters' is?

Sorry, I realized my mistake.  I will revise my patch within a few
days.





^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-06-03 16:24                                   ` kobarity
@ 2024-06-04 14:29                                     ` kobarity
  2024-06-05 10:25                                       ` Mattias Engdegård
  0 siblings, 1 reply; 49+ messages in thread
From: kobarity @ 2024-06-04 14:29 UTC (permalink / raw)
  To: Mattias Engdegård, Lin Sun; +Cc: Eli Zaretskii, Stefan Kangas, 70815

[-- Attachment #1: Type: text/plain, Size: 3635 bytes --]

kobarity wrote:
> 
> kobarity wrote:
> > Mattias Engdegård wrote:
> > > > 2. Revert 9c7de10079 and run ERTs.  The expectation is that the 7 ERTs
> > > >   that previously failed will succeed.
> > > 
> > > No, they still fail:
> > > 
> > > 7 unexpected results:
> > >    FAILED  python-completion-at-point-1
> > >    FAILED  python-completion-at-point-2
> > >    FAILED  python-completion-at-point-native-1
> > >    FAILED  python-completion-at-point-native-2
> > >    FAILED  python-completion-at-point-native-with-eldoc-1
> > >    FAILED  python-completion-at-point-native-with-ffap-1
> > >    FAILED  python-shell-completion-at-point-1
> > > 
> > > 2 skipped results:
> > >   SKIPPED  python-shell-completion-at-point-ipython
> > >   SKIPPED  python-shell-completion-at-point-jedi-completer
> > 
> > Maybe I did not make the right request.  What I wanted you to try was
> > to make the following changes after applying my patch in the previous
> > email.
> > 
> > diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
> > index 970ec32bc0c..77b30f8bdbc 100644
> > --- a/test/lisp/progmodes/python-tests.el
> > +++ b/test/lisp/progmodes/python-tests.el
> > @@ -3770,7 +3770,7 @@ python-tests-get-shell-interpreter
> >              ;; Use the same order as for the default value of
> >              ;; `python-shell-interpreter'.
> >              (delq nil (mapcar #'python-tests--get-interpreter-info
> > -                              '("python3" "python" "python2"))))))
> > +                              '("python" "python3" "python2"))))))
> >    (cl-some (or pred #'car) python-tests-shell-interpreters))
> > 
> >  (defun python-tests--get-interpreter-info (name)
> > 
> > If you have tried it this way, could you tell me what the value of
> > `python-tests-shell-interpreters' is?
> 
> Sorry, I realized my mistake.  I will revise my patch within a few
> days.

The attached is the revised patch.  In order to bind
`python-shell-interpreter' consistently, new macros
`python-tests-with-shell-interpreter' and
`python-tests-with-temp-buffer-with-shell-interpreter' were
introduced.  The patch is larger because some of the indentations have
been changed by using new macros.  I have fixed
`python-shell-interpreter' was not bound correctly in some ERTs, so
you might find new ERTs that fail with Python 2 on Mac.

Same as before, it would be helpful if you could try each of the
following on Mac.

1. Set EMACS_PYTHON_INTERPRETER environment variable to "python" and
   run ERTs.  The expectation is that the 7 ERTs that previously
   resulted in errors will be skipped.
2. Change the order of the interpreters in
   `python-tests-get-shell-interpreter' to  "python" "python3"
   "python2" and run ERTs.  The expectation is that the 7 ERTs that
   previously failed will succeed.

Another change is the behavior when the interpreter specified in
EMACS_PYTHON_INTERPRETER is not found.  In the current master, ERTs
are skipped if the interpreter specified by EMACS_PYTHON_INTERPRETER
is not found.  This is because although
`python-tests-get-shell-interpreter' raises an error, `skip-unless'
ignores it.

However, if the interpreter specified by EMACS_PYTHON_INTERPRETER is
not found, it is likely that EMACS_PYTHON_INTERPRETER is incorrectly
configured, and I would prefer to let it fail rather than let it be
skipped.  If it is better to be skipped, it would be better to have
`python-tests-get-shell-interpreter' return nil without raising an
error.  I would like to hear Lin's and others opinions on this matter.

[-- Attachment #2: 0001-Specify-Python-3-in-some-ERTs-on-Mac.patch --]
[-- Type: application/octet-stream, Size: 41276 bytes --]

From 8721e1e08543f0328f8bf822e64bfea6742d8abf Mon Sep 17 00:00:00 2001
From: kobarity <kobarity@gmail.com>
Date: Tue, 4 Jun 2024 21:51:32 +0900
Subject: [PATCH] Specify Python 3 in some ERTs on Mac

* test/lisp/progmodes/python-tests.el
(python-tests-with-temp-buffer-with-shell): Remove setting
'python-shell-interpreter'.
(python-tests-shell-interpreter): Removed.
(python-tests-shell-interpreters): New variable.
(python-tests-with-shell-interpreter)
(python-tests-with-temp-buffer-with-shell-interpreter): New macros.
(python-tests-get-shell-interpreter): Add an optional PRED
argument to allow ERts to specify Python interpreter version.
(python-tests--get-interpreter-info): New function.
(python-tests-interpreter-3-p): New function to be used as the
PRED argument of 'python-tests-get-shell-interpreter'.
(python-shell-make-comint-1)
(python-shell-make-comint-2)
(python-shell-make-comint-4)
(python-shell-get-process-1)
(python-shell-internal-get-or-create-process-1)
(python-shell-prompt-detect-1)
(python-shell-prompt-detect-2)
(python-shell-prompt-detect-3)
(python-shell-prompt-detect-4)
(python-shell-prompt-detect-5)
(python-shell-prompt-detect-6)
(python-shell-prompt-set-calculated-regexps-6)
(python-shell-completion-at-point-jedi-completer)
(python-completion-at-point-pdb-1)
(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)
(python-tests--run-python-selects-window)
(python-test--shell-send-block): Use the new macro.
(python-shell-completion-at-point-ipython): Remove setting
'python-tests-shell-interpreter'.
(python-shell-completion-at-point-1)
(python-completion-at-point-1)
(python-completion-at-point-2)
(python-completion-at-point-native-1)
(python-completion-at-point-native-2)
(python-completion-at-point-native-with-ffap-1)
(python-completion-at-point-native-with-eldoc-1): Use the new
macro and specify Python 3 on Mac to avoid errors.  (Bug#70815)
---
 test/lisp/progmodes/python-tests.el | 660 +++++++++++++++-------------
 1 file changed, 352 insertions(+), 308 deletions(-)

diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
index b06547b10ff..5fc773026e7 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -59,8 +59,7 @@ 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-interpreter (python-tests-get-shell-interpreter)))
+             (python-shell-completion-native-enable nil))
          (python-mode)
          (unwind-protect
              ;; Prevent test failures when Jedi is used as a completion
@@ -3750,21 +3749,67 @@ python-bob-infloop-avoid
 \f
 ;;; Shell integration
 
-(defvar python-tests-shell-interpreter nil)
-
-(defun python-tests-get-shell-interpreter ()
+(defvar python-tests-shell-interpreters nil
+  "List of Python interpreter information.
+Set this variable to nil to rescan interpreters.")
+
+(defmacro python-tests-with-shell-interpreter (pred &rest body)
+  "Bind `python-shell-interpreter' and execute BODY.
+`python-shell-interpreter' is bound to the result of calling
+`python-tests-get-shell-interpreter' with PRED argument.  The calling
+ERT is skipped if `python-tests-get-shell-interpreter' returned nil."
+  `(let ((python-shell-interpreter
+          (python-tests-get-shell-interpreter ,pred)))
+     (skip-unless python-shell-interpreter)
+     ,@body))
+
+(defmacro python-tests-with-temp-buffer-with-shell-interpreter
+    (pred contents &rest body)
+  "Variant of `python-tests-with-temp-buffer-with-shell'.
+It binds `python-shell-interpreter' to the result of calling
+`python-tests-get-shell-interpreter' with PRED argument, and calls
+`python-tests-with-temp-buffer-with-shell' with CONTENTS and BODY."
+  `(python-tests-with-shell-interpreter
+    ,pred
+    (python-tests-with-temp-buffer-with-shell ,contents ,@body)))
+
+(defun python-tests-get-shell-interpreter (&optional pred)
   "Get the shell interpreter.
-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
-          (or (when-let ((interpreter (getenv "EMACS_PYTHON_INTERPRETER")))
-                (or (executable-find interpreter)
-                    (error "Couldn't find EMACS_PYTHON_INTERPRETER(%s) in path"
-                           interpreter)))
-              ;; Use the same order as for the default value of
-              ;; `python-shell-interpreter'.
-              (cl-some #'executable-find '("python3" "python" "python2"))))))
+If an optional PRED is specified, an interpreter is selected that
+matches the predicate.  PRED must return the absolute file name if the
+condition is met.  If env string EMACS_PYTHON_INTERPRETER exists, use it
+as preferred one."
+  (unless python-tests-shell-interpreters
+    (setq python-tests-shell-interpreters
+          (if-let ((interpreter (getenv "EMACS_PYTHON_INTERPRETER")))
+              (if-let ((info (python-tests--get-interpreter-info interpreter)))
+                  (list info)
+                (error "Couldn't find EMACS_PYTHON_INTERPRETER(%s) in path"
+                       interpreter))
+            ;; Use the same order as for the default value of
+            ;; `python-shell-interpreter'.
+            (delq nil (mapcar #'python-tests--get-interpreter-info
+                              '("python3" "python" "python2"))))))
+  (cl-some (or pred #'car) python-tests-shell-interpreters))
+
+(defun python-tests--get-interpreter-info (name)
+  "Get Python interpreter information specified by NAME.
+The information returned is a cons cell consisting of the file path and
+the version string."
+  (when-let ((interpreter (executable-find name)))
+    (with-temp-buffer
+      (and (equal (call-process interpreter nil t nil "--version") 0)
+           (goto-char (point-min))
+           (looking-at
+            (rx (seq "Python" (+ space) (group (+ (any digit ?.))))))
+           (cons interpreter (match-string-no-properties 1))))))
+
+(defun python-tests-interpreter-3-p (info)
+  "Return the absolute file name if the interpreter major version in INFO is 3.
+This function is intended to be used as the PRED argument of
+`python-tests-get-shell-interpreter'."
+  (when (string= (car (split-string (cdr info) "\\.")) "3")
+    (car info)))
 
 (ert-deftest python-shell-get-process-name-1 ()
   "Check process name calculation sans `buffer-file-name'."
@@ -4026,48 +4071,46 @@ python-shell-with-environment-3
 
 (ert-deftest python-shell-make-comint-1 ()
   "Check comint creation for global shell buffer."
-  (skip-unless (python-tests-get-shell-interpreter))
   ;; The interpreter can get killed too quickly to allow it to clean
   ;; up the tempfiles that the default python-shell-setup-codes create,
   ;; so it leaves tempfiles behind, which is a minor irritation.
-  (let* ((python-shell-setup-codes nil)
-         (python-shell-interpreter
-          (python-tests-get-shell-interpreter))
-         (proc-name (python-shell-get-process-name nil))
-         (shell-buffer
-          (python-tests-with-temp-buffer
-           "" (python-shell-make-comint
-               (python-shell-calculate-command) proc-name)))
-         (process (get-buffer-process shell-buffer)))
-    (unwind-protect
-        (progn
-          (set-process-query-on-exit-flag process nil)
-          (should (process-live-p process))
-          (with-current-buffer shell-buffer
-            (should (eq major-mode 'inferior-python-mode))
-            (should (string= (buffer-name) (format "*%s*" proc-name)))))
-      (kill-buffer shell-buffer))))
+  (python-tests-with-shell-interpreter
+   nil
+   (let* ((python-shell-setup-codes nil)
+          (proc-name (python-shell-get-process-name nil))
+          (shell-buffer
+           (python-tests-with-temp-buffer
+            "" (python-shell-make-comint
+                (python-shell-calculate-command) proc-name)))
+          (process (get-buffer-process shell-buffer)))
+     (unwind-protect
+         (progn
+           (set-process-query-on-exit-flag process nil)
+           (should (process-live-p process))
+           (with-current-buffer shell-buffer
+             (should (eq major-mode 'inferior-python-mode))
+             (should (string= (buffer-name) (format "*%s*" proc-name)))))
+       (kill-buffer shell-buffer)))))
 
 (ert-deftest python-shell-make-comint-2 ()
   "Check comint creation for internal shell buffer."
-  (skip-unless (python-tests-get-shell-interpreter))
-  (let* ((python-shell-setup-codes nil)
-         (python-shell-interpreter
-          (python-tests-get-shell-interpreter))
-         (proc-name (python-shell-internal-get-process-name))
-         (shell-buffer
-          (python-tests-with-temp-buffer
-           "" (python-shell-make-comint
-               (python-shell-calculate-command) proc-name nil t)))
-         (process (get-buffer-process shell-buffer)))
-    (unwind-protect
-        (progn
-          (set-process-query-on-exit-flag process nil)
-          (should (process-live-p process))
-          (with-current-buffer shell-buffer
-            (should (eq major-mode 'inferior-python-mode))
-            (should (string= (buffer-name) (format " *%s*" proc-name)))))
-      (kill-buffer shell-buffer))))
+  (python-tests-with-shell-interpreter
+   nil
+   (let* ((python-shell-setup-codes nil)
+          (proc-name (python-shell-internal-get-process-name))
+          (shell-buffer
+           (python-tests-with-temp-buffer
+            "" (python-shell-make-comint
+                (python-shell-calculate-command) proc-name nil t)))
+          (process (get-buffer-process shell-buffer)))
+     (unwind-protect
+         (progn
+           (set-process-query-on-exit-flag process nil)
+           (should (process-live-p process))
+           (with-current-buffer shell-buffer
+             (should (eq major-mode 'inferior-python-mode))
+             (should (string= (buffer-name) (format " *%s*" proc-name)))))
+       (kill-buffer shell-buffer)))))
 
 (ert-deftest python-shell-make-comint-3 ()
   "Check comint creation with overridden python interpreter and args.
@@ -4099,58 +4142,56 @@ python-shell-make-comint-3
 
 (ert-deftest python-shell-make-comint-4 ()
   "Check shell calculated prompts regexps are set."
-  (skip-unless (python-tests-get-shell-interpreter))
-  (let* ((process-environment process-environment)
-         (python-shell-setup-codes nil)
-         (python-shell-interpreter
-          (python-tests-get-shell-interpreter))
-         (python-shell-interpreter-args "-i")
-         (python-shell--prompt-calculated-input-regexp nil)
-         (python-shell--prompt-calculated-output-regexp nil)
-         (python-shell-prompt-detect-enabled t)
-         (python-shell-prompt-input-regexps '("extralargeinputprompt" "sml"))
-         (python-shell-prompt-output-regexps '("extralargeoutputprompt" "sml"))
-         (python-shell-prompt-regexp "in")
-         (python-shell-prompt-block-regexp "block")
-         (python-shell-prompt-pdb-regexp "pdf")
-         (python-shell-prompt-output-regexp "output")
-         (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))
-         (proc-name (python-shell-get-process-name nil))
-         (shell-buffer
-          (progn
-            (setenv "PYTHONSTARTUP" startup-file)
-            (python-tests-with-temp-buffer
-             "" (python-shell-make-comint
-                 (python-shell-calculate-command) proc-name nil))))
-         (process (get-buffer-process shell-buffer)))
-    (unwind-protect
-        (progn
-          (set-process-query-on-exit-flag process nil)
-          (should (process-live-p process))
-          (with-current-buffer shell-buffer
-            (should (eq major-mode 'inferior-python-mode))
-            (should (string=
-                     python-shell--prompt-calculated-input-regexp
-                     (concat "^\\(extralargeinputprompt\\|\\.\\.> \\|"
-                             "block\\|py> \\|pdf\\|sml\\|in\\)")))
-            (should (string=
-                     python-shell--prompt-calculated-output-regexp
-                     "^\\(extralargeoutputprompt\\|output\\|out \\|sml\\)"))))
-      (delete-file startup-file)
-      (kill-buffer shell-buffer))))
+  (python-tests-with-shell-interpreter
+   nil
+   (let* ((process-environment process-environment)
+          (python-shell-setup-codes nil)
+          (python-shell-interpreter-args "-i")
+          (python-shell--prompt-calculated-input-regexp nil)
+          (python-shell--prompt-calculated-output-regexp nil)
+          (python-shell-prompt-detect-enabled t)
+          (python-shell-prompt-input-regexps '("extralargeinputprompt" "sml"))
+          (python-shell-prompt-output-regexps '("extralargeoutputprompt" "sml"))
+          (python-shell-prompt-regexp "in")
+          (python-shell-prompt-block-regexp "block")
+          (python-shell-prompt-pdb-regexp "pdf")
+          (python-shell-prompt-output-regexp "output")
+          (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))
+          (proc-name (python-shell-get-process-name nil))
+          (shell-buffer
+           (progn
+             (setenv "PYTHONSTARTUP" startup-file)
+             (python-tests-with-temp-buffer
+              "" (python-shell-make-comint
+                  (python-shell-calculate-command) proc-name nil))))
+          (process (get-buffer-process shell-buffer)))
+     (unwind-protect
+         (progn
+           (set-process-query-on-exit-flag process nil)
+           (should (process-live-p process))
+           (with-current-buffer shell-buffer
+             (should (eq major-mode 'inferior-python-mode))
+             (should (string=
+                      python-shell--prompt-calculated-input-regexp
+                      (concat "^\\(extralargeinputprompt\\|\\.\\.> \\|"
+                              "block\\|py> \\|pdf\\|sml\\|in\\)")))
+             (should (string=
+                      python-shell--prompt-calculated-output-regexp
+                      "^\\(extralargeoutputprompt\\|output\\|out \\|sml\\)"))))
+       (delete-file startup-file)
+       (kill-buffer shell-buffer)))))
 
 (ert-deftest python-shell-get-process-1 ()
   "Check dedicated shell process preference over global."
-  (skip-unless (python-tests-get-shell-interpreter))
-  (python-tests-with-temp-file
-      ""
+  (python-tests-with-shell-interpreter
+   nil
+   (python-tests-with-temp-file
+    ""
     (let* ((python-shell-setup-codes nil)
-           (python-shell-interpreter
-            (python-tests-get-shell-interpreter))
            (global-proc-name (python-shell-get-process-name nil))
            (dedicated-proc-name (python-shell-get-process-name t))
            (global-shell-buffer
@@ -4174,131 +4215,134 @@ python-shell-get-process-1
             ;; No buffer available.
             (should (not (python-shell-get-process))))
         (ignore-errors (kill-buffer global-shell-buffer))
-        (ignore-errors (kill-buffer dedicated-shell-buffer))))))
+        (ignore-errors (kill-buffer dedicated-shell-buffer)))))))
 
 (ert-deftest python-shell-internal-get-or-create-process-1 ()
   "Check internal shell process creation fallback."
-  (skip-unless (python-tests-get-shell-interpreter))
-  (python-tests-with-temp-file
-   ""
-   (should (not (process-live-p (python-shell-internal-get-process-name))))
-   (let* ((python-shell-interpreter
-           (python-tests-get-shell-interpreter))
-          (internal-process-name (python-shell-internal-get-process-name))
-          (internal-process (python-shell-internal-get-or-create-process))
-          (internal-shell-buffer (process-buffer internal-process)))
-     (unwind-protect
-         (progn
-           (set-process-query-on-exit-flag internal-process nil)
-           (should (equal (process-name internal-process)
-                          internal-process-name))
-           (should (equal internal-process
-                          (python-shell-internal-get-or-create-process)))
-           ;; Assert the internal process is not a user process
-           (should (not (python-shell-get-process)))
-           (kill-buffer internal-shell-buffer))
-       (ignore-errors (kill-buffer internal-shell-buffer))))))
+  (python-tests-with-shell-interpreter
+   nil
+   (python-tests-with-temp-file
+    ""
+    (should (not (process-live-p (python-shell-internal-get-process-name))))
+    (let* ((internal-process-name (python-shell-internal-get-process-name))
+           (internal-process (python-shell-internal-get-or-create-process))
+           (internal-shell-buffer (process-buffer internal-process)))
+      (unwind-protect
+          (progn
+            (set-process-query-on-exit-flag internal-process nil)
+            (should (equal (process-name internal-process)
+                           internal-process-name))
+            (should (equal internal-process
+                           (python-shell-internal-get-or-create-process)))
+            ;; Assert the internal process is not a user process
+            (should (not (python-shell-get-process)))
+            (kill-buffer internal-shell-buffer))
+        (ignore-errors (kill-buffer internal-shell-buffer)))))))
 
 (ert-deftest python-shell-prompt-detect-1 ()
   "Check prompt autodetection."
-  (skip-unless (python-tests-get-shell-interpreter))
-  (let ((process-environment process-environment)
-        (python-shell-interpreter (python-tests-get-shell-interpreter)))
-    ;; Ensure no startup file is enabled
-    (setenv "PYTHONSTARTUP" "")
-    (should python-shell-prompt-detect-enabled)
-    (should (equal (python-shell-prompt-detect) '(">>> " "... " "")))))
+  (python-tests-with-shell-interpreter
+   nil
+   (let ((process-environment process-environment))
+     ;; Ensure no startup file is enabled
+     (setenv "PYTHONSTARTUP" "")
+     (should python-shell-prompt-detect-enabled)
+     (should (equal (python-shell-prompt-detect) '(">>> " "... " ""))))))
 
 (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)))
-    (unwind-protect
-        (progn
-          ;; Ensure startup file is enabled
-          (setenv "PYTHONSTARTUP" startup-file)
-          (should python-shell-prompt-detect-enabled)
-          (should (equal (python-shell-prompt-detect) '("py> " "..> " "out "))))
-      (ignore-errors (delete-file startup-file)))))
+  (python-tests-with-shell-interpreter
+   nil
+   (let* ((process-environment process-environment)
+          (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)))
+     (unwind-protect
+         (progn
+           ;; Ensure startup file is enabled
+           (setenv "PYTHONSTARTUP" startup-file)
+           (should python-shell-prompt-detect-enabled)
+           (should (equal (python-shell-prompt-detect) '("py> " "..> " "out "))))
+       (ignore-errors (delete-file startup-file))))))
 
 (ert-deftest python-shell-prompt-detect-3 ()
   "Check prompts are not autodetected when feature is disabled."
-  (skip-unless (python-tests-get-shell-interpreter))
-  (let ((process-environment process-environment)
-        (python-shell-prompt-detect-enabled nil))
-    ;; Ensure no startup file is enabled
-    (should (not python-shell-prompt-detect-enabled))
-    (should (not (python-shell-prompt-detect)))))
+  (python-tests-with-shell-interpreter
+   nil
+   (let ((process-environment process-environment)
+         (python-shell-prompt-detect-enabled nil))
+     ;; Ensure no startup file is enabled
+     (should (not python-shell-prompt-detect-enabled))
+     (should (not (python-shell-prompt-detect))))))
 
 (ert-deftest python-shell-prompt-detect-4 ()
   "Check warning is shown when detection fails."
-  (skip-unless (python-tests-get-shell-interpreter))
-  (let* ((process-environment process-environment)
-         ;; Trigger failure by removing prompts in the startup file
-         (startup-code (concat "import sys\n"
-                               "sys.ps1 = ''\n"
-                               "sys.ps2 = ''\n"
-                               "sys.ps3 = ''\n"))
-         (startup-file (python-shell--save-temp-file startup-code)))
-    (unwind-protect
-        (progn
-          (kill-buffer (get-buffer-create "*Warnings*"))
-          (should (not (get-buffer "*Warnings*")))
-          (setenv "PYTHONSTARTUP" startup-file)
-          (should python-shell-prompt-detect-failure-warning)
-          (should python-shell-prompt-detect-enabled)
-          (should (not (python-shell-prompt-detect)))
-          (should (get-buffer "*Warnings*")))
-      (ignore-errors (delete-file startup-file)))))
+  (python-tests-with-shell-interpreter
+   nil
+   (let* ((process-environment process-environment)
+          ;; Trigger failure by removing prompts in the startup file
+          (startup-code (concat "import sys\n"
+                                "sys.ps1 = ''\n"
+                                "sys.ps2 = ''\n"
+                                "sys.ps3 = ''\n"))
+          (startup-file (python-shell--save-temp-file startup-code)))
+     (unwind-protect
+         (progn
+           (kill-buffer (get-buffer-create "*Warnings*"))
+           (should (not (get-buffer "*Warnings*")))
+           (setenv "PYTHONSTARTUP" startup-file)
+           (should python-shell-prompt-detect-failure-warning)
+           (should python-shell-prompt-detect-enabled)
+           (should (not (python-shell-prompt-detect)))
+           (should (get-buffer "*Warnings*")))
+       (ignore-errors (delete-file startup-file))))))
 
 (ert-deftest python-shell-prompt-detect-5 ()
   "Check disabled warnings are not shown when detection fails."
-  (skip-unless (python-tests-get-shell-interpreter))
-  (let* ((process-environment process-environment)
-         (startup-code (concat "import sys\n"
-                               "sys.ps1 = ''\n"
-                               "sys.ps2 = ''\n"
-                               "sys.ps3 = ''\n"))
-         (startup-file (python-shell--save-temp-file startup-code))
-         (python-shell-prompt-detect-failure-warning nil))
-    (unwind-protect
-        (progn
-          (kill-buffer (get-buffer-create "*Warnings*"))
-          (should (not (get-buffer "*Warnings*")))
-          (setenv "PYTHONSTARTUP" startup-file)
-          (should (not python-shell-prompt-detect-failure-warning))
-          (should python-shell-prompt-detect-enabled)
-          (should (not (python-shell-prompt-detect)))
-          (should (not (get-buffer "*Warnings*"))))
-      (ignore-errors (delete-file startup-file)))))
+  (python-tests-with-shell-interpreter
+   nil
+   (let* ((process-environment process-environment)
+          (startup-code (concat "import sys\n"
+                                "sys.ps1 = ''\n"
+                                "sys.ps2 = ''\n"
+                                "sys.ps3 = ''\n"))
+          (startup-file (python-shell--save-temp-file startup-code))
+          (python-shell-prompt-detect-failure-warning nil))
+     (unwind-protect
+         (progn
+           (kill-buffer (get-buffer-create "*Warnings*"))
+           (should (not (get-buffer "*Warnings*")))
+           (setenv "PYTHONSTARTUP" startup-file)
+           (should (not python-shell-prompt-detect-failure-warning))
+           (should python-shell-prompt-detect-enabled)
+           (should (not (python-shell-prompt-detect)))
+           (should (not (get-buffer "*Warnings*"))))
+       (ignore-errors (delete-file startup-file))))))
 
 (ert-deftest python-shell-prompt-detect-6 ()
   "Warnings are not shown when detection is disabled."
-  (skip-unless (python-tests-get-shell-interpreter))
-  (let* ((process-environment process-environment)
-         (startup-code (concat "import sys\n"
-                               "sys.ps1 = ''\n"
-                               "sys.ps2 = ''\n"
-                               "sys.ps3 = ''\n"))
-         (startup-file (python-shell--save-temp-file startup-code))
-         (python-shell-prompt-detect-failure-warning t)
-         (python-shell-prompt-detect-enabled nil))
-    (unwind-protect
-        (progn
-          (kill-buffer (get-buffer-create "*Warnings*"))
-          (should (not (get-buffer "*Warnings*")))
-          (setenv "PYTHONSTARTUP" startup-file)
-          (should python-shell-prompt-detect-failure-warning)
-          (should (not python-shell-prompt-detect-enabled))
-          (should (not (python-shell-prompt-detect)))
-          (should (not (get-buffer "*Warnings*"))))
-      (ignore-errors (delete-file startup-file)))))
+  (python-tests-with-shell-interpreter
+   nil
+   (let* ((process-environment process-environment)
+          (startup-code (concat "import sys\n"
+                                "sys.ps1 = ''\n"
+                                "sys.ps2 = ''\n"
+                                "sys.ps3 = ''\n"))
+          (startup-file (python-shell--save-temp-file startup-code))
+          (python-shell-prompt-detect-failure-warning t)
+          (python-shell-prompt-detect-enabled nil))
+     (unwind-protect
+         (progn
+           (kill-buffer (get-buffer-create "*Warnings*"))
+           (should (not (get-buffer "*Warnings*")))
+           (setenv "PYTHONSTARTUP" startup-file)
+           (should python-shell-prompt-detect-failure-warning)
+           (should (not python-shell-prompt-detect-enabled))
+           (should (not (python-shell-prompt-detect)))
+           (should (not (get-buffer "*Warnings*"))))
+       (ignore-errors (delete-file startup-file))))))
 
 (ert-deftest python-shell-prompt-validate-regexps-1 ()
   "Check `python-shell-prompt-input-regexps' are validated."
@@ -4444,32 +4488,32 @@ python-shell-prompt-set-calculated-regexps-5
 
 (ert-deftest python-shell-prompt-set-calculated-regexps-6 ()
   "Check detected prompts are included `regexp-quote'd."
-  (skip-unless (python-tests-get-shell-interpreter))
-  (let* ((python-shell-prompt-input-regexps '(""))
-         (python-shell-prompt-output-regexps '(""))
-         (python-shell-prompt-regexp "")
-         (python-shell-prompt-block-regexp "")
-         (python-shell-prompt-pdb-regexp "")
-         (python-shell-prompt-output-regexp "")
-         (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"
-                               "sys.ps2 = '..> '\n"
-                               "sys.ps3 = 'o.t '\n"))
-         (startup-file (python-shell--save-temp-file startup-code)))
-    (unwind-protect
-        (progn
-          (setenv "PYTHONSTARTUP" startup-file)
-          (python-shell-prompt-set-calculated-regexps)
-          (should (string= python-shell--prompt-calculated-input-regexp
-                           "^\\(\\.\\.> \\|p\\.> \\|\\)"))
-          (should (string= python-shell--prompt-calculated-output-regexp
-                           "^\\(o\\.t \\|\\)")))
-      (ignore-errors (delete-file startup-file)))))
+  (python-tests-with-shell-interpreter
+   nil
+   (let* ((python-shell-prompt-input-regexps '(""))
+          (python-shell-prompt-output-regexps '(""))
+          (python-shell-prompt-regexp "")
+          (python-shell-prompt-block-regexp "")
+          (python-shell-prompt-pdb-regexp "")
+          (python-shell-prompt-output-regexp "")
+          (python-shell--prompt-calculated-input-regexp nil)
+          (python-shell--prompt-calculated-output-regexp nil)
+          (python-shell-prompt-detect-enabled t)
+          (process-environment process-environment)
+          (startup-code (concat "import sys\n"
+                                "sys.ps1 = 'p.> '\n"
+                                "sys.ps2 = '..> '\n"
+                                "sys.ps3 = 'o.t '\n"))
+          (startup-file (python-shell--save-temp-file startup-code)))
+     (unwind-protect
+         (progn
+           (setenv "PYTHONSTARTUP" startup-file)
+           (python-shell-prompt-set-calculated-regexps)
+           (should (string= python-shell--prompt-calculated-input-regexp
+                            "^\\(\\.\\.> \\|p\\.> \\|\\)"))
+           (should (string= python-shell--prompt-calculated-output-regexp
+                            "^\\(o\\.t \\|\\)")))
+       (ignore-errors (delete-file startup-file))))))
 
 (ert-deftest python-shell-buffer-substring-1 ()
   "Selecting a substring of the whole buffer must match its contents."
@@ -4828,8 +4872,8 @@ python-shell-completion-native-interpreter-disabled-p-1
     (should (python-shell-completion-native-interpreter-disabled-p))))
 
 (ert-deftest python-shell-completion-at-point-1 ()
-  (skip-unless (python-tests-get-shell-interpreter))
-  (python-tests-with-temp-buffer-with-shell
+  (python-tests-with-temp-buffer-with-shell-interpreter
+   (when (eq system-type 'darwin) #'python-tests-interpreter-3-p)
    ""
    (python-shell-with-shell-buffer
      (skip-unless python-shell-readline-completer-delims)
@@ -4842,8 +4886,8 @@ python-shell-completion-at-point-1
      (should-not (nth 2 (python-shell-completion-at-point))))))
 
 (ert-deftest python-shell-completion-at-point-native-1 ()
-  (skip-unless (python-tests-get-shell-interpreter))
-  (python-tests-with-temp-buffer-with-shell
+  (python-tests-with-temp-buffer-with-shell-interpreter
+   nil
    ""
    (python-shell-completion-native-turn-on)
    (python-shell-with-shell-buffer
@@ -4928,25 +4972,25 @@ python-tests--pythonstartup-file
 
 (ert-deftest python-shell-completion-at-point-jedi-completer ()
   "Check if Python shell completion works when Jedi completer is used."
-  (skip-unless (python-tests-get-shell-interpreter))
-  (with-environment-variables
-      (("PYTHONSTARTUP" (python-tests--pythonstartup-file)))
-    (python-tests-with-temp-buffer-with-shell
-     ""
-     (python-shell-with-shell-buffer
-       (skip-unless (string= python-shell-readline-completer-delims ""))
-       (python-shell-completion-native-turn-off)
-       (python-tests--completion-module)
-       (python-tests--completion-parameters)
-       (python-shell-completion-native-turn-on)
-       (python-tests--completion-module)
-       (python-tests--completion-parameters)
-       (python-tests--completion-extra-context)))))
+  (python-tests-with-shell-interpreter
+   nil
+   (with-environment-variables
+       (("PYTHONSTARTUP" (python-tests--pythonstartup-file)))
+     (python-tests-with-temp-buffer-with-shell
+      ""
+      (python-shell-with-shell-buffer
+        (skip-unless (string= python-shell-readline-completer-delims ""))
+        (python-shell-completion-native-turn-off)
+        (python-tests--completion-module)
+        (python-tests--completion-parameters)
+        (python-shell-completion-native-turn-on)
+        (python-tests--completion-module)
+        (python-tests--completion-parameters)
+        (python-tests--completion-extra-context))))))
 
 (ert-deftest python-shell-completion-at-point-ipython ()
   "Check if Python shell completion works for IPython."
-  (let ((python-tests-shell-interpreter "ipython")
-        (python-shell-interpreter "ipython")
+  (let ((python-shell-interpreter "ipython")
         (python-shell-interpreter-args "-i --simple-prompt"))
     (skip-unless
      (and
@@ -4973,8 +5017,8 @@ python-shell-completion-at-point-ipython
 ;;; Symbol completion
 
 (ert-deftest python-completion-at-point-1 ()
-  (skip-unless (python-tests-get-shell-interpreter))
-  (python-tests-with-temp-buffer-with-shell
+  (python-tests-with-temp-buffer-with-shell-interpreter
+   (when (eq system-type 'darwin) #'python-tests-interpreter-3-p)
    "
 import abc
 "
@@ -4991,8 +5035,8 @@ python-completion-at-point-1
 
 (ert-deftest python-completion-at-point-2 ()
   "Should work regardless of the point in the Shell buffer."
-  (skip-unless (python-tests-get-shell-interpreter))
-  (python-tests-with-temp-buffer-with-shell
+  (python-tests-with-temp-buffer-with-shell-interpreter
+   (when (eq system-type 'darwin) #'python-tests-interpreter-3-p)
    "
 import abc
 "
@@ -5009,8 +5053,8 @@ python-completion-at-point-2
 
 (ert-deftest python-completion-at-point-pdb-1 ()
   "Should not complete PDB commands in Python buffer."
-  (skip-unless (python-tests-get-shell-interpreter))
-  (python-tests-with-temp-buffer-with-shell
+  (python-tests-with-temp-buffer-with-shell-interpreter
+   nil
    "
 import pdb
 
@@ -5028,8 +5072,8 @@ python-completion-at-point-pdb-1
 
 (ert-deftest python-completion-at-point-while-running-1 ()
   "Should not try to complete when a program is running in the Shell buffer."
-  (skip-unless (python-tests-get-shell-interpreter))
-  (python-tests-with-temp-buffer-with-shell
+  (python-tests-with-temp-buffer-with-shell-interpreter
+   nil
    "
 import time
 
@@ -5044,8 +5088,8 @@ python-completion-at-point-while-running-1
      (should-not (with-timeout (1 t) (completion-at-point))))))
 
 (ert-deftest python-completion-at-point-native-1 ()
-  (skip-unless (python-tests-get-shell-interpreter))
-  (python-tests-with-temp-buffer-with-shell
+  (python-tests-with-temp-buffer-with-shell-interpreter
+   (when (eq system-type 'darwin) #'python-tests-interpreter-3-p)
    "
 import abc
 "
@@ -5063,8 +5107,8 @@ python-completion-at-point-native-1
 
 (ert-deftest python-completion-at-point-native-2 ()
   "Should work regardless of the point in the Shell buffer."
-  (skip-unless (python-tests-get-shell-interpreter))
-  (python-tests-with-temp-buffer-with-shell
+  (python-tests-with-temp-buffer-with-shell-interpreter
+   (when (eq system-type 'darwin) #'python-tests-interpreter-3-p)
    "
 import abc
 "
@@ -5081,8 +5125,8 @@ python-completion-at-point-native-2
      (should (completion-at-point)))))
 
 (ert-deftest python-completion-at-point-native-with-ffap-1 ()
-  (skip-unless (python-tests-get-shell-interpreter))
-  (python-tests-with-temp-buffer-with-shell
+  (python-tests-with-temp-buffer-with-shell-interpreter
+   (when (eq system-type 'darwin) #'python-tests-interpreter-3-p)
    "
 import abc
 "
@@ -5099,8 +5143,8 @@ python-completion-at-point-native-with-ffap-1
      (should (completion-at-point)))))
 
 (ert-deftest python-completion-at-point-native-with-eldoc-1 ()
-  (skip-unless (python-tests-get-shell-interpreter))
-  (python-tests-with-temp-buffer-with-shell
+  (python-tests-with-temp-buffer-with-shell-interpreter
+   (when (eq system-type 'darwin) #'python-tests-interpreter-3-p)
    "
 import abc
 "
@@ -5126,8 +5170,8 @@ python-completion-at-point-native-with-eldoc-1
 ;;; FFAP
 
 (ert-deftest python-ffap-module-path-1 ()
-  (skip-unless (python-tests-get-shell-interpreter))
-  (python-tests-with-temp-buffer-with-shell
+  (python-tests-with-temp-buffer-with-shell-interpreter
+   nil
    "
 import abc
 "
@@ -5138,8 +5182,8 @@ python-ffap-module-path-1
 
 (ert-deftest python-ffap-module-path-while-running-1 ()
   "Should not get module path when a program is running in the Shell buffer."
-  (skip-unless (python-tests-get-shell-interpreter))
-  (python-tests-with-temp-buffer-with-shell
+  (python-tests-with-temp-buffer-with-shell-interpreter
+   nil
    "
 import abc
 import time
@@ -5214,8 +5258,8 @@ python-eldoc--get-symbol-at-point-4
                     "some_symbol"))))
 
 (ert-deftest python-eldoc--get-doc-at-point-1 ()
-  (skip-unless (python-tests-get-shell-interpreter))
-  (python-tests-with-temp-buffer-with-shell
+  (python-tests-with-temp-buffer-with-shell-interpreter
+   nil
    "
 import time
 "
@@ -5227,8 +5271,8 @@ python-eldoc--get-doc-at-point-1
 
 (ert-deftest python-eldoc--get-doc-at-point-while-running-1 ()
   "Should not get documentation when a program is running in the Shell buffer."
-  (skip-unless (python-tests-get-shell-interpreter))
-  (python-tests-with-temp-buffer-with-shell
+  (python-tests-with-temp-buffer-with-shell-interpreter
+   nil
    "
 import time
 
@@ -7445,18 +7489,18 @@ python-tests--python-nav-end-of-statement--infloop
 ;; interpreter.
 (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* ((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
-    ;; be synchronized with the former when returning to the "command
-    ;; loop"; until then, `current-buffer' can change arbitrarily.
-    (should (eq window (selected-window)))
-    (pop-to-buffer (other-buffer))
-    (run-python nil nil 'show)
-    (should (eq window (selected-window)))))
+  (python-tests-with-shell-interpreter
+   nil
+   (let* ((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
+     ;; be synchronized with the former when returning to the "command
+     ;; loop"; until then, `current-buffer' can change arbitrarily.
+     (should (eq window (selected-window)))
+     (pop-to-buffer (other-buffer))
+     (run-python nil nil 'show)
+     (should (eq window (selected-window))))))
 
 (ert-deftest python-tests--fill-long-first-line ()
   (should
@@ -7517,31 +7561,31 @@ python-tests--flymake-command-output-pattern
                        "W0611: Unused import a.b.c (unused-import)"))))))
 
 (ert-deftest python-test--shell-send-block ()
-  (skip-unless (python-tests-get-shell-interpreter))
-  (python-tests-with-temp-buffer-with-shell
-    "print('current 0')
+  (python-tests-with-temp-buffer-with-shell-interpreter
+   nil
+   "print('current 0')
 for x in range(1,3):
     print('current %s' % x)
 print('current 3')"
-    (goto-char (point-min))
-    (should-error (python-shell-send-block) :type 'user-error)
-    (forward-line)
-    (python-shell-send-block t) ;; send block with header
-    (python-tests-shell-wait-for-prompt)
-    (python-shell-with-shell-buffer
-      (goto-char (point-min))
-      (should-not (re-search-forward "current 0" nil t))
-      (should (re-search-forward "current 1" nil t))
-      (should (re-search-forward "current 2" nil t))
-      (should-not (re-search-forward "current 3" nil t)))
-    (forward-line)
-    (python-shell-send-block) ;; send block body only
-    (python-tests-shell-wait-for-prompt)
-    (python-shell-with-shell-buffer
-      ;; should only 1 line output from the block body
-      (should (re-search-forward "current"))
-      (should (looking-at " 2"))
-      (should-not (re-search-forward "current" nil t)))))
+   (goto-char (point-min))
+   (should-error (python-shell-send-block) :type 'user-error)
+   (forward-line)
+   (python-shell-send-block t) ;; send block with header
+   (python-tests-shell-wait-for-prompt)
+   (python-shell-with-shell-buffer
+     (goto-char (point-min))
+     (should-not (re-search-forward "current 0" nil t))
+     (should (re-search-forward "current 1" nil t))
+     (should (re-search-forward "current 2" nil t))
+     (should-not (re-search-forward "current 3" nil t)))
+   (forward-line)
+   (python-shell-send-block) ;; send block body only
+   (python-tests-shell-wait-for-prompt)
+   (python-shell-with-shell-buffer
+     ;; should only 1 line output from the block body
+     (should (re-search-forward "current"))
+     (should (looking-at " 2"))
+     (should-not (re-search-forward "current" nil t)))))
 
 ;;; python-ts-mode font-lock tests
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-06-04 14:29                                     ` kobarity
@ 2024-06-05 10:25                                       ` Mattias Engdegård
  2024-06-05 11:52                                         ` kobarity
  0 siblings, 1 reply; 49+ messages in thread
From: Mattias Engdegård @ 2024-06-05 10:25 UTC (permalink / raw)
  To: kobarity; +Cc: Eli Zaretskii, Lin Sun, Stefan Kangas, 70815

4 juni 2024 kl. 16.29 skrev kobarity <kobarity@gmail.com>:

> The attached is the revised patch.  In order to bind
> `python-shell-interpreter' consistently, new macros
> `python-tests-with-shell-interpreter' and
> `python-tests-with-temp-buffer-with-shell-interpreter' were
> introduced.  The patch is larger because some of the indentations have
> been changed by using new macros.  I have fixed
> `python-shell-interpreter' was not bound correctly in some ERTs, so
> you might find new ERTs that fail with Python 2 on Mac.

It works here.

> 1. Set EMACS_PYTHON_INTERPRETER environment variable to "python" and
>   run ERTs.  The expectation is that the 7 ERTs that previously
>   resulted in errors will be skipped.

Yes.

> 2. Change the order of the interpreters in
>   `python-tests-get-shell-interpreter' to  "python" "python3"
>   "python2" and run ERTs.  The expectation is that the 7 ERTs that
>   previously failed will succeed.

Yes.

> However, if the interpreter specified by EMACS_PYTHON_INTERPRETER is
> not found, it is likely that EMACS_PYTHON_INTERPRETER is incorrectly
> configured, and I would prefer to let it fail rather than let it be
> skipped.

Yes, which is what happens with your patch, and I agree that this is the best outcome.

Would you like me to push your patch?






^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-06-05 10:25                                       ` Mattias Engdegård
@ 2024-06-05 11:52                                         ` kobarity
  2024-06-08 15:34                                           ` kobarity
  0 siblings, 1 reply; 49+ messages in thread
From: kobarity @ 2024-06-05 11:52 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: Eli Zaretskii, Lin Sun, Stefan Kangas, 70815

Mattias Engdegård wrote:
> 
> 4 juni 2024 kl. 16.29 skrev kobarity <kobarity@gmail.com>:
> 
> > The attached is the revised patch.  In order to bind
> > `python-shell-interpreter' consistently, new macros
> > `python-tests-with-shell-interpreter' and
> > `python-tests-with-temp-buffer-with-shell-interpreter' were
> > introduced.  The patch is larger because some of the indentations have
> > been changed by using new macros.  I have fixed
> > `python-shell-interpreter' was not bound correctly in some ERTs, so
> > you might find new ERTs that fail with Python 2 on Mac.
> 
> It works here.
> 
> > 1. Set EMACS_PYTHON_INTERPRETER environment variable to "python" and
> >   run ERTs.  The expectation is that the 7 ERTs that previously
> >   resulted in errors will be skipped.
> 
> Yes.
> 
> > 2. Change the order of the interpreters in
> >   `python-tests-get-shell-interpreter' to  "python" "python3"
> >   "python2" and run ERTs.  The expectation is that the 7 ERTs that
> >   previously failed will succeed.
> 
> Yes.
> 
> > However, if the interpreter specified by EMACS_PYTHON_INTERPRETER is
> > not found, it is likely that EMACS_PYTHON_INTERPRETER is incorrectly
> > configured, and I would prefer to let it fail rather than let it be
> > skipped.
> 
> Yes, which is what happens with your patch, and I agree that this is the best outcome.

Thanks for the early confirmation.

> Would you like me to push your patch?

Thanks again.  I will wait a few days to see if I can get feedback
from others.





^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-06-05 11:52                                         ` kobarity
@ 2024-06-08 15:34                                           ` kobarity
  2024-06-09 13:58                                             ` Mattias Engdegård
  0 siblings, 1 reply; 49+ messages in thread
From: kobarity @ 2024-06-08 15:34 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: Eli Zaretskii, Lin Sun, Stefan Kangas, 70815

kobarity wrote:
> 
> Mattias Engdegård wrote:
> > 
> > 4 juni 2024 kl. 16.29 skrev kobarity <kobarity@gmail.com>:
> > 
> > > The attached is the revised patch.  In order to bind
> > > `python-shell-interpreter' consistently, new macros
> > > `python-tests-with-shell-interpreter' and
> > > `python-tests-with-temp-buffer-with-shell-interpreter' were
> > > introduced.  The patch is larger because some of the indentations have
> > > been changed by using new macros.  I have fixed
> > > `python-shell-interpreter' was not bound correctly in some ERTs, so
> > > you might find new ERTs that fail with Python 2 on Mac.
> > 
> > It works here.
> > 
> > > 1. Set EMACS_PYTHON_INTERPRETER environment variable to "python" and
> > >   run ERTs.  The expectation is that the 7 ERTs that previously
> > >   resulted in errors will be skipped.
> > 
> > Yes.
> > 
> > > 2. Change the order of the interpreters in
> > >   `python-tests-get-shell-interpreter' to  "python" "python3"
> > >   "python2" and run ERTs.  The expectation is that the 7 ERTs that
> > >   previously failed will succeed.
> > 
> > Yes.
> > 
> > > However, if the interpreter specified by EMACS_PYTHON_INTERPRETER is
> > > not found, it is likely that EMACS_PYTHON_INTERPRETER is incorrectly
> > > configured, and I would prefer to let it fail rather than let it be
> > > skipped.
> > 
> > Yes, which is what happens with your patch, and I agree that this is the best outcome.
> 
> Thanks for the early confirmation.
> 
> > Would you like me to push your patch?
> 
> Thanks again.  I will wait a few days to see if I can get feedback
> from others.

Since there doesn't seem to be any other feedback, could you please
apply the patch?





^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-06-08 15:34                                           ` kobarity
@ 2024-06-09 13:58                                             ` Mattias Engdegård
  2024-06-10 14:57                                               ` kobarity
  0 siblings, 1 reply; 49+ messages in thread
From: Mattias Engdegård @ 2024-06-09 13:58 UTC (permalink / raw)
  To: kobarity; +Cc: Eli Zaretskii, Lin Sun, Stefan Kangas, 70815

8 juni 2024 kl. 17.34 skrev kobarity <kobarity@gmail.com>:

> Since there doesn't seem to be any other feedback, could you please
> apply the patch?

Certainly, now pushed to master.






^ permalink raw reply	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-06-09 13:58                                             ` Mattias Engdegård
@ 2024-06-10 14:57                                               ` kobarity
  2024-06-10 15:44                                                 ` Mattias Engdegård
  0 siblings, 1 reply; 49+ messages in thread
From: kobarity @ 2024-06-10 14:57 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: Eli Zaretskii, Lin Sun, Stefan Kangas, 70815

[-- Attachment #1: Type: text/plain, Size: 310 bytes --]

Mattias Engdegård wrote:
> 
> 8 juni 2024 kl. 17.34 skrev kobarity <kobarity@gmail.com>:
> 
> > Since there doesn't seem to be any other feedback, could you please
> > apply the patch?
> 
> Certainly, now pushed to master.

Thanks.  I overlooked one thing.  Could you also apply the attached
patch?

[-- Attachment #2: 0001-Fix-recent-change-to-python-tests.el.patch --]
[-- Type: application/octet-stream, Size: 1086 bytes --]

From 9d2adecfc08579041618e2327c9941d6c8f4067b Mon Sep 17 00:00:00 2001
From: kobarity <kobarity@gmail.com>
Date: Mon, 10 Jun 2024 23:50:11 +0900
Subject: [PATCH] ; Fix recent change to python-tests.el

* test/lisp/progmodes/python-tests.el
(python-tests--pythonstartup-file): Use already bound
'python-shell-interpreter'.  (Bug#70815)
---
 test/lisp/progmodes/python-tests.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
index ce103921454..31b1c80a571 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -4974,7 +4974,7 @@ python-tests--pythonstartup-file
   "Return Jedi readline setup file if PYTHONSTARTUP is not set."
   (or (getenv "PYTHONSTARTUP")
       (with-temp-buffer
-        (if (eql 0 (call-process (python-tests-get-shell-interpreter)
+        (if (eql 0 (call-process python-shell-interpreter
                                  nil t nil "-m" "jedi" "repl"))
             (string-trim (buffer-string))
           ""))))
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters
  2024-06-10 14:57                                               ` kobarity
@ 2024-06-10 15:44                                                 ` Mattias Engdegård
  0 siblings, 0 replies; 49+ messages in thread
From: Mattias Engdegård @ 2024-06-10 15:44 UTC (permalink / raw)
  To: kobarity; +Cc: Eli Zaretskii, Lin Sun, Stefan Kangas, 70815

10 juni 2024 kl. 16.57 skrev kobarity <kobarity@gmail.com>:

> Thanks.  I overlooked one thing.  Could you also apply the attached
> patch?

Of course, pushed.







^ permalink raw reply	[flat|nested] 49+ messages in thread

end of thread, other threads:[~2024-06-10 15:44 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.