From 335690bed1964c7b629f26fe77282639d6c860a8 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Mon, 22 Aug 2022 12:23:27 -0400 Subject: [PATCH] gh-96076: Change test_launcher to use non-admin location for py.ini (GH-96091) Patch authored by Eryksun. (cherry picked from commit 216ccacda193733ef92146c8ac1eb81893b4478d) Co-authored-by: Terry Jan Reedy --- Lib/test/test_launcher.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_launcher.py b/Lib/test/test_launcher.py index 4ff847737277d5..8ef1f5df8b4571 100644 --- a/Lib/test/test_launcher.py +++ b/Lib/test/test_launcher.py @@ -239,9 +239,11 @@ def run_py(self, args, env=None, allow_fail=False, expect_returncode=0, argv=Non return data def py_ini(self, content): - if not self.py_exe: - self.py_exe = self.find_py() - return PreservePyIni(self.py_exe.with_name("py.ini"), content) + local_appdata = os.environ.get("LOCALAPPDATA") + if not local_appdata: + raise unittest.SkipTest("LOCALAPPDATA environment variable is " + "missing or empty") + return PreservePyIni(Path(local_appdata) / "py.ini", content) @contextlib.contextmanager def script(self, content, encoding="utf-8"):