]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-100192: fix `asyncio` subprocess tests to pass env vars to subprocess (#100569)
authorKumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Wed, 28 Dec 2022 05:46:04 +0000 (11:16 +0530)
committerGitHub <noreply@github.com>
Wed, 28 Dec 2022 05:46:04 +0000 (11:16 +0530)
Lib/test/test_asyncio/test_subprocess.py

index 1ae290a003f2128d23a75f38e90bd10a74174111..f1ad10a9903fe8626663d872a1be5d0fadf9d97b 100644 (file)
@@ -698,7 +698,8 @@ class SubprocessMixin:
     def test_create_subprocess_env_shell(self) -> None:
         async def main() -> None:
             cmd = f'''{sys.executable} -c "import os, sys; sys.stdout.write(os.getenv('FOO'))"'''
-            env = {"FOO": 'bar'}
+            env = os.environ.copy()
+            env["FOO"] = "bar"
             proc = await asyncio.create_subprocess_shell(
                 cmd, env=env, stdout=subprocess.PIPE
             )
@@ -710,7 +711,8 @@ class SubprocessMixin:
         async def main() -> None:
             cmd = [sys.executable, "-c",
                    "import os, sys; sys.stdout.write(os.getenv('FOO'))"]
-            env = {"FOO": 'baz'}
+            env = os.environ.copy()
+            env["FOO"] = "baz"
             proc = await asyncio.create_subprocess_exec(
                 *cmd, env=env, stdout=subprocess.PIPE
             )