gh-155491: Fix subprocess test_encoding_warning() (#155492)

vstinner <[email protected]> Mon, 10 Aug 2026 14:25:02 -0400 (EDT)
Newsgroups gmane.comp.python.cvs
Message-ID <[email protected]>
https://github.com/python/cpython/commit/433c842b39a9b930b7e2d6aafeca722fd68a3323
commit: 433c842b39a9b930b7e2d6aafeca722fd68a3323
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2026-08-10T20:24:48+02:00
summary:

gh-155491: Fix subprocess test_encoding_warning() (#155492)

The test fails if run using PYTHONWARNINGS=error environment
variable. Use make_clean_env() function to not inherit PYTHON
environment variables.

files:
M Lib/test/test_subprocess.py

diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 4cea07b3d2c774..fc94b9a972828c 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -2051,8 +2051,9 @@ def test_encoding_warning(self):
             run("echo hello", shell=True, text=True)
             check_output("echo hello", shell=True, text=True)
             """)
+        env = support.make_clean_env()
         cp = subprocess.run([sys.executable, "-Xwarn_default_encoding", "-c", code],
-                            capture_output=True)
+                            capture_output=True, env=env)
         lines = cp.stderr.splitlines()
         self.assertEqual(len(lines), 2, lines)
         self.assertStartsWith(lines[0], b"<string>:2: EncodingWarning: ")

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]