]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-96076: Change test_launcher to use non-admin location for py.ini (GH-96091)
authorTerry Jan Reedy <tjreedy@udel.edu>
Mon, 22 Aug 2022 16:23:27 +0000 (12:23 -0400)
committerGitHub <noreply@github.com>
Mon, 22 Aug 2022 16:23:27 +0000 (17:23 +0100)
Patch authored by Eryksun.

Lib/test/test_launcher.py

index 835a51e3b6e01123d2ad3a4c8b2a694cc65498ab..9e265901b188699707c40e49f257ed36b518123d 100644 (file)
@@ -238,9 +238,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"):