diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index 6b541da52310a3b..9b14c376a4f8c12 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -2015,8 +2015,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.assertTrue(lines[0].startswith(b":2: EncodingWarning: "))