From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: kobarity Newsgroups: gmane.emacs.bugs Subject: bug#70815: [PATCH] ; Enahnce python-tests.el to adapt different python interpreters Date: Tue, 21 May 2024 00:52:34 +0900 Message-ID: References: <86zfsmbb3b.fsf@gnu.org> Mime-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: multipart/mixed; boundary="Multipart_Tue_May_21_00:52:33_2024-1" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19157"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?Q?Goj=C5=8D?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.0.50 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) Cc: Eli Zaretskii , Stefan Kangas , 70815@debbugs.gnu.org To: Lin Sun Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 20 17:55:18 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1s95M6-0004hx-Cf for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 20 May 2024 17:55:18 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s95Lp-0003AF-F7; Mon, 20 May 2024 11:55:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s95Lm-00039a-4I for bug-gnu-emacs@gnu.org; Mon, 20 May 2024 11:54:59 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s95Ll-0006u3-S7 for bug-gnu-emacs@gnu.org; Mon, 20 May 2024 11:54:57 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s95Lq-0003h1-5B for bug-gnu-emacs@gnu.org; Mon, 20 May 2024 11:55:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: kobarity Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 20 May 2024 15:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70815 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 70815-submit@debbugs.gnu.org id=B70815.171622045914164 (code B ref 70815); Mon, 20 May 2024 15:55:02 +0000 Original-Received: (at 70815) by debbugs.gnu.org; 20 May 2024 15:54:19 +0000 Original-Received: from localhost ([127.0.0.1]:43304 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s95L9-0003gO-A0 for submit@debbugs.gnu.org; Mon, 20 May 2024 11:54:19 -0400 Original-Received: from mail-pl1-f174.google.com ([209.85.214.174]:59743) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s95L4-0003g8-Hu for 70815@debbugs.gnu.org; Mon, 20 May 2024 11:54:18 -0400 Original-Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1eecc71311eso80270295ad.3 for <70815@debbugs.gnu.org>; Mon, 20 May 2024 08:54:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716220383; x=1716825183; darn=debbugs.gnu.org; h=mime-version:user-agent:references:in-reply-to:subject:cc:to:from :message-id:date:from:to:cc:subject:date:message-id:reply-to; bh=LUdQnwyxqLRrNB7viTbBeOql6GLi9USK41JEx1ION8w=; b=R+jYUkyjg02LczOQ6JJKXa/ztHGf5rfDhOahzYFUBF9AqF7ToHo5cf5XmCM0jRp08Z OC0e8LLhnjIcI8wm01wdsorjqybVkKdd/C/phOrGOBlNaxNQdgSCT7qezzs59Xhf1CoM DX6B3sioP1jkyo8xs+lzMoAgfDZqJxWBc6lreJBs7ppnym3nsHUKcKez0MaQT2u9V9O4 LEjyq7ZBrbqtTRAeXu6SOF5U0XEJZVX4KHS7hGVi2oGbC7YftYEdd7p5iqPh8Hs9tKBY B9wZM9ehhgxjqu/2sgAsu48K5lAxZaFQ3uY4nTM1lZ6VSEZ5E6ZLAivt7UGM8sQPS8I5 cRPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716220383; x=1716825183; h=mime-version:user-agent:references:in-reply-to:subject:cc:to:from :message-id:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=LUdQnwyxqLRrNB7viTbBeOql6GLi9USK41JEx1ION8w=; b=Tv3IBJRHSNJw8FoFA9rwX59vucoc2n2E8J9ahZ9ueJgrkAsV25iNDzuXX4KiKG1Qs1 UwT6NjRy+XtiI72uuZnd6NI53g7OqVRKt5ZTQWEFQGJIlmRsCuhDPCY7ZbVdTPgWHRaB 6Z3/+R/GLu6uo/Dw/2erm+GsB1YoZVN3qLnPRRo4VrANxdin2wEgpeAf+zU/BHGTLGq2 uuGigWNpRUPoUrGHrTjS3TISq+iNNE1VmtVVojfIhO1GSPWniLS4wWhBIJLMbSkqxyqc DEclXT0J44uly8aSzmJJ1ofJylZbkujbgxJHLDXzBdQrzJvXOHVoPZ57LAwPXdh3JqBv e89w== X-Forwarded-Encrypted: i=1; AJvYcCUz/Bdhll9KqH3263gpgOPCKNtqIGO8Cco+EDSpRNCNAejM65r765KwfVRjpGUtMGM/+SlqBk1HCArjN5TxhZi304/ltrA= X-Gm-Message-State: AOJu0Yw21Pczjdgi091zmaNIchyokVOQVGTQnAFv7KdiuFBr12dW/ZEl Xtn+Jm+jfs/8kpp3mJ2Z+LwcvhruTS8uZJlE11RQjou0Vqx336UK X-Google-Smtp-Source: AGHT+IHq7azgQo9xwdLW1jsb82eOqkV7f8cx2WNAGlqpths+SPAG9rVIbQo/xWhj0Xs2vvsbB1LMkg== X-Received: by 2002:a17:90a:780f:b0:2bd:69a4:b886 with SMTP id 98e67ed59e1d1-2bd69a4ba8fmr6751509a91.26.1716220383359; Mon, 20 May 2024 08:53:03 -0700 (PDT) Original-Received: from localhost (58x12x133x161.ap58.ftth.ucom.ne.jp. [58.12.133.161]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2b628861725sm24247286a91.22.2024.05.20.08.53.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 08:53:02 -0700 (PDT) In-Reply-To: <86zfsmbb3b.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:285480 Archived-At: --Multipart_Tue_May_21_00:52:33_2024-1 Content-Type: text/plain; charset=US-ASCII Eli Zaretskii wrote: > > Cc: kobarity > > From: Stefan Kangas > > 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. --Multipart_Tue_May_21_00:52:33_2024-1 Content-Type: application/octet-stream; type=patch; name="fix-70815.diff" Content-Disposition: attachment; filename="fix-70815.diff" Content-Transfer-Encoding: 7bit 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 --Multipart_Tue_May_21_00:52:33_2024-1--