gh-96076: Change test_launcher to use non-admin location for py.ini (GH-96091)

Patch authored by Eryksun.
This commit is contained in:
Terry Jan Reedy 2022-08-22 12:23:27 -04:00 committed by GitHub
parent 18b1782192
commit 216ccacda1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View 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"):