]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-96076: Change test_launcher to use non-admin location for py.ini (GH-96091)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 22 Aug 2022 16:49:34 +0000 (09:49 -0700)
committerGitHub <noreply@github.com>
Mon, 22 Aug 2022 16:49:34 +0000 (09:49 -0700)
Patch authored by Eryksun.
(cherry picked from commit 216ccacda193733ef92146c8ac1eb81893b4478d)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Lib/test/test_launcher.py

index 4ff847737277d5f40b1724ffa987233403fce7fa..8ef1f5df8b45715376dd94334efe8ac0efebea8f 100644 (file)
@@ -239,9 +239,11 @@ class RunPyMixin:
         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"):